@velum-labs/routekit-eval-setup 1.3.2 → 1.5.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/dist/adapters/authoring-responses-request.d.ts +5 -0
- package/dist/adapters/authoring-responses-request.js +38 -0
- package/dist/adapters/evaluation-evidence-freshness.d.ts +7 -0
- package/dist/adapters/evaluation-evidence-freshness.js +76 -0
- package/dist/adapters/git-task-history.d.ts +67 -0
- package/dist/adapters/git-task-history.js +171 -0
- package/dist/adapters/integrated-repository-history.d.ts +21 -0
- package/dist/adapters/integrated-repository-history.js +175 -0
- package/dist/adapters/repository-command-diagnostic.d.ts +8 -0
- package/dist/adapters/repository-command-diagnostic.js +46 -0
- package/dist/adapters/repository-command-evidence.d.ts +13 -0
- package/dist/adapters/repository-command-evidence.js +102 -0
- package/dist/adapters/repository-command-runner.d.ts +238 -0
- package/dist/adapters/repository-command-runner.js +1483 -0
- package/dist/adapters/repository-import-context.d.ts +47 -0
- package/dist/adapters/repository-import-context.js +469 -0
- package/dist/adapters/repository-node-test-reporter.d.ts +3 -0
- package/dist/adapters/repository-node-test-reporter.js +27 -0
- package/dist/adapters/repository-review-evidence.d.ts +39 -0
- package/dist/adapters/repository-review-evidence.js +632 -0
- package/dist/adapters/repository-seed-selection.d.ts +7 -0
- package/dist/adapters/repository-seed-selection.js +79 -0
- package/dist/adapters/repository-solution-edits.d.ts +49 -0
- package/dist/adapters/repository-solution-edits.js +136 -0
- package/dist/adapters/repository-vitest-phase-adapter.d.ts +8 -0
- package/dist/adapters/repository-vitest-phase-adapter.js +310 -0
- package/dist/adapters/repository-vitest-reporter.d.ts +24 -0
- package/dist/adapters/repository-vitest-reporter.js +314 -0
- package/dist/adapters/strict-authoring-schema.d.ts +5 -0
- package/dist/adapters/strict-authoring-schema.js +158 -0
- package/dist/adapters/test-discovery.d.ts +30 -0
- package/dist/adapters/test-discovery.js +124 -0
- package/dist/adapters/typescript-repository-index.d.ts +51 -0
- package/dist/adapters/typescript-repository-index.js +226 -0
- package/dist/agentic-capabilities-protocol.d.ts +1373 -0
- package/dist/agentic-capabilities-protocol.js +786 -0
- package/dist/case-checkpoint-store.d.ts +29 -0
- package/dist/case-checkpoint-store.js +133 -0
- package/dist/case-pipeline-protocol-v2.d.ts +184 -0
- package/dist/case-pipeline-protocol-v2.js +193 -0
- package/dist/case-pipeline-protocol.d.ts +2626 -0
- package/dist/case-pipeline-protocol.js +371 -0
- package/dist/effect-api.d.ts +74 -10
- package/dist/effect-api.js +56 -6
- package/dist/errors.d.ts +31 -0
- package/dist/errors.js +10 -0
- package/dist/eval-capability-execution-envelope.d.ts +64 -0
- package/dist/eval-capability-execution-envelope.js +98 -0
- package/dist/eval-capability-policy.d.ts +90 -0
- package/dist/eval-capability-policy.js +107 -0
- package/dist/eval-event-log.d.ts +140 -0
- package/dist/eval-event-log.js +220 -0
- package/dist/evaluation-authoring-policy.d.ts +18 -0
- package/dist/evaluation-authoring-policy.js +19 -0
- package/dist/evaluation-authoring-validation.d.ts +22 -0
- package/dist/evaluation-authoring-validation.js +72 -0
- package/dist/evaluation-evidence.d.ts +20 -0
- package/dist/evaluation-evidence.js +319 -0
- package/dist/evaluation-grader-calibration-protocol.d.ts +108 -0
- package/dist/evaluation-grader-calibration-protocol.js +80 -0
- package/dist/evaluation-grader-calibration.d.ts +18 -0
- package/dist/evaluation-grader-calibration.js +334 -0
- package/dist/evaluation-grading-policy.d.ts +24 -0
- package/dist/evaluation-grading-policy.js +54 -0
- package/dist/evaluation-proposal-policy.d.ts +4 -0
- package/dist/evaluation-proposal-policy.js +91 -0
- package/dist/evaluation-source-retrieval.d.ts +68 -0
- package/dist/evaluation-source-retrieval.js +513 -0
- package/dist/evaluation-structure-policy.d.ts +29 -0
- package/dist/evaluation-structure-policy.js +138 -0
- package/dist/index.d.ts +124 -17
- package/dist/index.js +69 -11
- package/dist/inspection.js +2 -3
- package/dist/project-artifacts.d.ts +7 -2
- package/dist/project-artifacts.js +49 -136
- package/dist/project-authoring.d.ts +66 -5
- package/dist/project-authoring.js +783 -109
- package/dist/project-contracts.d.ts +419 -84
- package/dist/project-contracts.js +160 -52
- package/dist/project-store.js +2 -1
- package/dist/project-workflow.d.ts +5 -4
- package/dist/project-workflow.js +154 -35
- package/dist/repository-adversary-protocol.d.ts +64 -0
- package/dist/repository-adversary-protocol.js +105 -0
- package/dist/repository-behavior-protocol.d.ts +188 -0
- package/dist/repository-behavior-protocol.js +202 -0
- package/dist/repository-benchmark-protocol.d.ts +487 -0
- package/dist/repository-benchmark-protocol.js +96 -0
- package/dist/repository-execution-protocol.d.ts +150 -0
- package/dist/repository-execution-protocol.js +38 -0
- package/dist/repository-fixture-instructions.d.ts +3 -0
- package/dist/repository-fixture-instructions.js +91 -0
- package/dist/repository-fixture-protocol.d.ts +79 -0
- package/dist/repository-fixture-protocol.js +79 -0
- package/dist/repository-foundry-plan-protocol.d.ts +118 -0
- package/dist/repository-foundry-plan-protocol.js +296 -0
- package/dist/repository-foundry-progress-protocol.d.ts +52 -0
- package/dist/repository-foundry-progress-protocol.js +52 -0
- package/dist/repository-improvement-protocol.d.ts +100 -0
- package/dist/repository-improvement-protocol.js +106 -0
- package/dist/repository-language-model-protocol.d.ts +43 -0
- package/dist/repository-language-model-protocol.js +146 -0
- package/dist/repository-oracle-coverage-protocol.d.ts +18 -0
- package/dist/repository-oracle-coverage-protocol.js +39 -0
- package/dist/repository-oracle-execution-binding.d.ts +27 -0
- package/dist/repository-oracle-execution-binding.js +59 -0
- package/dist/repository-oracle-protocol.d.ts +230 -0
- package/dist/repository-oracle-protocol.js +156 -0
- package/dist/repository-oracle-scope-policy.d.ts +22 -0
- package/dist/repository-oracle-scope-policy.js +92 -0
- package/dist/repository-quality-policy.d.ts +15 -0
- package/dist/repository-quality-policy.js +357 -0
- package/dist/repository-routing-benchmark-protocol.d.ts +176 -0
- package/dist/repository-routing-benchmark-protocol.js +103 -0
- package/dist/repository-routing-model-protocol.d.ts +36 -0
- package/dist/repository-routing-model-protocol.js +89 -0
- package/dist/repository-routing-plan-protocol.d.ts +112 -0
- package/dist/repository-routing-plan-protocol.js +58 -0
- package/dist/repository-routing-quality-policy.d.ts +9 -0
- package/dist/repository-routing-quality-policy.js +191 -0
- package/dist/repository-seed-qualification-progress-protocol.d.ts +205 -0
- package/dist/repository-seed-qualification-progress-protocol.js +28 -0
- package/dist/repository-semantic-calibration-protocol.d.ts +768 -0
- package/dist/repository-semantic-calibration-protocol.js +276 -0
- package/dist/repository-semantic-calibration.d.ts +163 -0
- package/dist/repository-semantic-calibration.js +581 -0
- package/dist/repository-specification-contract-facts-protocol.d.ts +224 -0
- package/dist/repository-specification-contract-facts-protocol.js +276 -0
- package/dist/repository-specification-critique-protocol.d.ts +189 -0
- package/dist/repository-specification-critique-protocol.js +103 -0
- package/dist/repository-task-family-protocol.d.ts +24 -0
- package/dist/repository-task-family-protocol.js +37 -0
- package/dist/repository-task-seed-protocol.d.ts +384 -0
- package/dist/repository-task-seed-protocol.js +236 -0
- package/dist/repository-trajectory-protocol.d.ts +20 -0
- package/dist/repository-trajectory-protocol.js +42 -0
- package/dist/service.js +1 -1
- package/dist/services/adversary/service.d.ts +64 -0
- package/dist/services/adversary/service.js +330 -0
- package/dist/services/benchmark-compiler/service.d.ts +450 -0
- package/dist/services/benchmark-compiler/service.js +9 -0
- package/dist/services/budgeted-model/service.d.ts +118 -0
- package/dist/services/budgeted-model/service.js +460 -0
- package/dist/services/case-authoring/service.d.ts +163 -0
- package/dist/services/case-authoring/service.js +1456 -0
- package/dist/services/case-finalization/service.d.ts +283 -0
- package/dist/services/case-finalization/service.js +370 -0
- package/dist/services/case-generation/service.d.ts +619 -0
- package/dist/services/case-generation/service.js +2628 -0
- package/dist/services/case-pipeline/service.d.ts +31 -0
- package/dist/services/case-pipeline/service.js +485 -0
- package/dist/services/case-pipeline-v2/service.d.ts +70 -0
- package/dist/services/case-pipeline-v2/service.js +477 -0
- package/dist/services/command-observability/service.d.ts +13 -0
- package/dist/services/command-observability/service.js +3 -0
- package/dist/services/dimension-labeling/service.d.ts +77 -0
- package/dist/services/dimension-labeling/service.js +188 -0
- package/dist/services/eval-candidate/service.d.ts +208 -0
- package/dist/services/eval-candidate/service.js +64 -0
- package/dist/services/eval-capabilities/service.d.ts +183 -0
- package/dist/services/eval-capabilities/service.js +1433 -0
- package/dist/services/eval-environment/service.d.ts +173 -0
- package/dist/services/eval-environment/service.js +127 -0
- package/dist/services/evidence-reconstruction/service.d.ts +36 -0
- package/dist/services/evidence-reconstruction/service.js +145 -0
- package/dist/services/fixture-builder/service.d.ts +62 -0
- package/dist/services/fixture-builder/service.js +36 -0
- package/dist/services/fixture-validation/service.d.ts +75 -0
- package/dist/services/fixture-validation/service.js +295 -0
- package/dist/services/foundry/service.d.ts +831 -0
- package/dist/services/foundry/service.js +442 -0
- package/dist/services/foundry-progress/service.d.ts +62 -0
- package/dist/services/foundry-progress/service.js +149 -0
- package/dist/services/foundry-v2/service.d.ts +54 -0
- package/dist/services/foundry-v2/service.js +28 -0
- package/dist/services/grounded-authoring/service.d.ts +126 -0
- package/dist/services/grounded-authoring/service.js +822 -0
- package/dist/services/historical-case/service.d.ts +722 -0
- package/dist/services/historical-case/service.js +177 -0
- package/dist/services/improvement-loop/service.d.ts +59 -0
- package/dist/services/improvement-loop/service.js +176 -0
- package/dist/services/language-model/service.d.ts +52 -0
- package/dist/services/language-model/service.js +194 -0
- package/dist/services/oracle-builder/service.d.ts +146 -0
- package/dist/services/oracle-builder/service.js +513 -0
- package/dist/services/oracle-coverage/service.d.ts +28 -0
- package/dist/services/oracle-coverage/service.js +50 -0
- package/dist/services/oracle-coverage-witness/service.d.ts +130 -0
- package/dist/services/oracle-coverage-witness/service.js +538 -0
- package/dist/services/pipeline-challenge/service.d.ts +551 -0
- package/dist/services/pipeline-challenge/service.js +427 -0
- package/dist/services/pipeline-controls/service.d.ts +130 -0
- package/dist/services/pipeline-controls/service.js +483 -0
- package/dist/services/pipeline-oracle/service.d.ts +8 -0
- package/dist/services/pipeline-oracle/service.js +256 -0
- package/dist/services/pipeline-seed/service.d.ts +298 -0
- package/dist/services/pipeline-seed/service.js +428 -0
- package/dist/services/pipeline-spec/service.d.ts +103 -0
- package/dist/services/pipeline-spec/service.js +619 -0
- package/dist/services/pipeline-tournament/service.d.ts +258 -0
- package/dist/services/pipeline-tournament/service.js +476 -0
- package/dist/services/quality-gate/service.d.ts +233 -0
- package/dist/services/quality-gate/service.js +136 -0
- package/dist/services/repository-bundle/service.d.ts +33 -0
- package/dist/services/repository-bundle/service.js +114 -0
- package/dist/services/repository-model/service.d.ts +105 -0
- package/dist/services/repository-model/service.js +250 -0
- package/dist/services/repository-public-artifact/service.d.ts +133 -0
- package/dist/services/repository-public-artifact/service.js +330 -0
- package/dist/services/routing-benchmark/service.d.ts +362 -0
- package/dist/services/routing-benchmark/service.js +96 -0
- package/dist/services/specification-critic/service.d.ts +92 -0
- package/dist/services/specification-critic/service.js +172 -0
- package/dist/services/task-family/service.d.ts +40 -0
- package/dist/services/task-family/service.js +55 -0
- package/dist/services/task-seed/service.d.ts +906 -0
- package/dist/services/task-seed/service.js +1406 -0
- package/dist/services/task-specification/service.d.ts +27 -0
- package/dist/services/task-specification/service.js +40 -0
- package/dist/services/trajectory-policy/service.d.ts +110 -0
- package/dist/services/trajectory-policy/service.js +216 -0
- package/dist/test/agentic-capabilities-protocol.test.d.ts +1 -0
- package/dist/test/agentic-capabilities-protocol.test.js +570 -0
- package/dist/test/agentic-capabilities.test.d.ts +1 -0
- package/dist/test/agentic-capabilities.test.js +1461 -0
- package/dist/test/agentic-environment.test.d.ts +1 -0
- package/dist/test/agentic-environment.test.js +213 -0
- package/dist/test/case-pipeline-foundation.test.d.ts +1 -0
- package/dist/test/case-pipeline-foundation.test.js +535 -0
- package/dist/test/case-pipeline-protocol-v2.test.d.ts +1 -0
- package/dist/test/case-pipeline-protocol-v2.test.js +124 -0
- package/dist/test/case-pipeline-v2.test.d.ts +1 -0
- package/dist/test/case-pipeline-v2.test.js +286 -0
- package/dist/test/case-pipeline.test.d.ts +1 -0
- package/dist/test/case-pipeline.test.js +851 -0
- package/dist/test/eval-capability-policy.test.d.ts +1 -0
- package/dist/test/eval-capability-policy.test.js +50 -0
- package/dist/test/eval-event-log.test.d.ts +1 -0
- package/dist/test/eval-event-log.test.js +125 -0
- package/dist/test/evaluation-evidence-freshness.test.d.ts +1 -0
- package/dist/test/evaluation-evidence-freshness.test.js +44 -0
- package/dist/test/evaluation-evidence.test.d.ts +1 -0
- package/dist/test/evaluation-evidence.test.js +230 -0
- package/dist/test/evaluation-grader-calibration.test.d.ts +1 -0
- package/dist/test/evaluation-grader-calibration.test.js +373 -0
- package/dist/test/evaluation-proposal-digest.test.d.ts +1 -0
- package/dist/test/evaluation-proposal-digest.test.js +187 -0
- package/dist/test/evaluation-source-retrieval.test.d.ts +1 -0
- package/dist/test/evaluation-source-retrieval.test.js +237 -0
- package/dist/test/evaluation-structure-policy.test.d.ts +1 -0
- package/dist/test/evaluation-structure-policy.test.js +196 -0
- package/dist/test/fixtures/repository-resource-panel.d.ts +39 -0
- package/dist/test/fixtures/repository-resource-panel.js +111 -0
- package/dist/test/fixtures/vitest-boundary-panel.d.ts +84 -0
- package/dist/test/fixtures/vitest-boundary-panel.js +120 -0
- package/dist/test/fixtures/vitest-phase-panel.d.ts +135 -0
- package/dist/test/fixtures/vitest-phase-panel.js +213 -0
- package/dist/test/fixtures/vitest-reporter-results.d.ts +76 -0
- package/dist/test/fixtures/vitest-reporter-results.js +94 -0
- package/dist/test/grounded-authoring.test.d.ts +1 -0
- package/dist/test/grounded-authoring.test.js +565 -0
- package/dist/test/integrated-repository-history.test.d.ts +1 -0
- package/dist/test/integrated-repository-history.test.js +227 -0
- package/dist/test/project-authoring.test.js +593 -43
- package/dist/test/project-workflow.test.js +419 -40
- package/dist/test/repository-authoring-artifacts.test.d.ts +1 -0
- package/dist/test/repository-authoring-artifacts.test.js +185 -0
- package/dist/test/repository-bundle.test.d.ts +1 -0
- package/dist/test/repository-bundle.test.js +52 -0
- package/dist/test/repository-case-generation.test.d.ts +1 -0
- package/dist/test/repository-case-generation.test.js +3465 -0
- package/dist/test/repository-command-diagnostic.test.d.ts +1 -0
- package/dist/test/repository-command-diagnostic.test.js +55 -0
- package/dist/test/repository-command-signals.test.d.ts +1 -0
- package/dist/test/repository-command-signals.test.js +124 -0
- package/dist/test/repository-fixture-scope-coverage.test.d.ts +1 -0
- package/dist/test/repository-fixture-scope-coverage.test.js +127 -0
- package/dist/test/repository-fixture-validation.test.d.ts +1 -0
- package/dist/test/repository-fixture-validation.test.js +362 -0
- package/dist/test/repository-foundry-progress.test.d.ts +1 -0
- package/dist/test/repository-foundry-progress.test.js +110 -0
- package/dist/test/repository-foundry-quality.test.d.ts +1 -0
- package/dist/test/repository-foundry-quality.test.js +1138 -0
- package/dist/test/repository-import-context.test.d.ts +1 -0
- package/dist/test/repository-import-context.test.js +354 -0
- package/dist/test/repository-model-authoring.test.d.ts +1 -0
- package/dist/test/repository-model-authoring.test.js +544 -0
- package/dist/test/repository-model.test.d.ts +1 -0
- package/dist/test/repository-model.test.js +2195 -0
- package/dist/test/repository-node-test-reporter.test.d.ts +1 -0
- package/dist/test/repository-node-test-reporter.test.js +104 -0
- package/dist/test/repository-oracle-concurrency.test.d.ts +1 -0
- package/dist/test/repository-oracle-concurrency.test.js +542 -0
- package/dist/test/repository-oracle-coverage-witness.test.d.ts +1 -0
- package/dist/test/repository-oracle-coverage-witness.test.js +511 -0
- package/dist/test/repository-oracle-coverage.test.d.ts +1 -0
- package/dist/test/repository-oracle-coverage.test.js +168 -0
- package/dist/test/repository-oracle-evidence.test.d.ts +1 -0
- package/dist/test/repository-oracle-evidence.test.js +185 -0
- package/dist/test/repository-oracle-plan.test.d.ts +1 -0
- package/dist/test/repository-oracle-plan.test.js +176 -0
- package/dist/test/repository-overlay-isolation.test.d.ts +1 -0
- package/dist/test/repository-overlay-isolation.test.js +85 -0
- package/dist/test/repository-preparation-cache.test.d.ts +1 -0
- package/dist/test/repository-preparation-cache.test.js +414 -0
- package/dist/test/repository-public-artifact.test.d.ts +1 -0
- package/dist/test/repository-public-artifact.test.js +273 -0
- package/dist/test/repository-qualification-diagnostics.test.d.ts +1 -0
- package/dist/test/repository-qualification-diagnostics.test.js +524 -0
- package/dist/test/repository-reference-authoring.test.d.ts +1 -0
- package/dist/test/repository-reference-authoring.test.js +1633 -0
- package/dist/test/repository-review-evidence-v2.test.d.ts +1 -0
- package/dist/test/repository-review-evidence-v2.test.js +183 -0
- package/dist/test/repository-review-evidence.test.d.ts +1 -0
- package/dist/test/repository-review-evidence.test.js +124 -0
- package/dist/test/repository-seed-exclusions.test.d.ts +1 -0
- package/dist/test/repository-seed-exclusions.test.js +96 -0
- package/dist/test/repository-seed-selection.test.d.ts +1 -0
- package/dist/test/repository-seed-selection.test.js +504 -0
- package/dist/test/repository-semantic-calibration.test.d.ts +1 -0
- package/dist/test/repository-semantic-calibration.test.js +688 -0
- package/dist/test/repository-solution-edits.test.d.ts +1 -0
- package/dist/test/repository-solution-edits.test.js +377 -0
- package/dist/test/repository-specification-budget.test.d.ts +1 -0
- package/dist/test/repository-specification-budget.test.js +171 -0
- package/dist/test/repository-specification-contract-checkpoint.test.d.ts +1 -0
- package/dist/test/repository-specification-contract-checkpoint.test.js +228 -0
- package/dist/test/repository-specification-contract-facts.test.d.ts +1 -0
- package/dist/test/repository-specification-contract-facts.test.js +177 -0
- package/dist/test/repository-trajectory-authoring.test.d.ts +1 -0
- package/dist/test/repository-trajectory-authoring.test.js +176 -0
- package/dist/test/repository-valid-control-plan.test.d.ts +1 -0
- package/dist/test/repository-valid-control-plan.test.js +45 -0
- package/dist/test/repository-vitest-phase.test.d.ts +1 -0
- package/dist/test/repository-vitest-phase.test.js +848 -0
- package/dist/test/repository-vitest-reporter.test.d.ts +1 -0
- package/dist/test/repository-vitest-reporter.test.js +158 -0
- package/dist/test/repository-workspace-build.test.d.ts +1 -0
- package/dist/test/repository-workspace-build.test.js +160 -0
- package/dist/test/strict-authoring-schema.test.d.ts +1 -0
- package/dist/test/strict-authoring-schema.test.js +169 -0
- package/package.json +48 -6
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { posix } from "node:path";
|
|
3
|
+
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
|
|
4
|
+
const bytes = (value) => Buffer.byteLength(value, "utf8");
|
|
5
|
+
const evidenceId = (input) => `ev_${sha256([
|
|
6
|
+
input.path,
|
|
7
|
+
input.sourceDigest,
|
|
8
|
+
String(input.ordinal),
|
|
9
|
+
sha256(input.text)
|
|
10
|
+
].join("\u0000")).slice(0, 24)}`;
|
|
11
|
+
const splitOversizedText = (text, maximumBytes) => {
|
|
12
|
+
const fragments = [];
|
|
13
|
+
let fragment = "";
|
|
14
|
+
let fragmentBytes = 0;
|
|
15
|
+
for (const character of text) {
|
|
16
|
+
const characterBytes = bytes(character);
|
|
17
|
+
if (fragmentBytes + characterBytes > maximumBytes && fragment.length > 0) {
|
|
18
|
+
fragments.push(fragment);
|
|
19
|
+
fragment = "";
|
|
20
|
+
fragmentBytes = 0;
|
|
21
|
+
}
|
|
22
|
+
fragment += character;
|
|
23
|
+
fragmentBytes += characterBytes;
|
|
24
|
+
}
|
|
25
|
+
if (fragment.length > 0)
|
|
26
|
+
fragments.push(fragment);
|
|
27
|
+
return fragments;
|
|
28
|
+
};
|
|
29
|
+
const lineFragments = (content, maximumBytes) => {
|
|
30
|
+
const lines = content.match(/[^\n]*\n|[^\n]+$/gu) ?? [];
|
|
31
|
+
return lines.flatMap((line, index) => {
|
|
32
|
+
const lineNumber = index + 1;
|
|
33
|
+
const fragments = bytes(line) <= maximumBytes
|
|
34
|
+
? [line]
|
|
35
|
+
: splitOversizedText(line, maximumBytes);
|
|
36
|
+
return fragments.map((text, fragmentIndex) => ({
|
|
37
|
+
text,
|
|
38
|
+
line: lineNumber,
|
|
39
|
+
blankBoundary: fragmentIndex === fragments.length - 1 &&
|
|
40
|
+
line.replace(/\r?\n$/u, "").trim().length === 0
|
|
41
|
+
}));
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const blockFragments = (fragments, maximumBytes) => {
|
|
45
|
+
const blocks = [];
|
|
46
|
+
let pending = [...fragments];
|
|
47
|
+
while (pending.length > 0) {
|
|
48
|
+
let admittedBytes = 0;
|
|
49
|
+
let admittedCount = 0;
|
|
50
|
+
let lastBlankBoundary = 0;
|
|
51
|
+
while (admittedCount < pending.length) {
|
|
52
|
+
const next = pending[admittedCount];
|
|
53
|
+
const nextBytes = bytes(next.text);
|
|
54
|
+
if (admittedBytes + nextBytes > maximumBytes)
|
|
55
|
+
break;
|
|
56
|
+
admittedBytes += nextBytes;
|
|
57
|
+
admittedCount += 1;
|
|
58
|
+
if (next.blankBoundary)
|
|
59
|
+
lastBlankBoundary = admittedCount;
|
|
60
|
+
}
|
|
61
|
+
if (admittedCount === 0) {
|
|
62
|
+
throw new Error("evidence fragment exceeds the configured byte bound");
|
|
63
|
+
}
|
|
64
|
+
const boundary = admittedCount < pending.length && lastBlankBoundary > 0
|
|
65
|
+
? lastBlankBoundary
|
|
66
|
+
: admittedCount;
|
|
67
|
+
blocks.push(pending.slice(0, boundary));
|
|
68
|
+
pending = pending.slice(boundary);
|
|
69
|
+
}
|
|
70
|
+
return blocks;
|
|
71
|
+
};
|
|
72
|
+
const assertSourcePath = (path) => {
|
|
73
|
+
const segments = path.split("/");
|
|
74
|
+
if (path.length === 0 ||
|
|
75
|
+
path.includes("\u0000") ||
|
|
76
|
+
path.includes("\\") ||
|
|
77
|
+
posix.isAbsolute(path) ||
|
|
78
|
+
posix.normalize(path) !== path ||
|
|
79
|
+
segments.includes(".") ||
|
|
80
|
+
segments.includes("..") ||
|
|
81
|
+
segments.some((segment) => segment.length === 0)) {
|
|
82
|
+
throw new Error(`evidence source path is not canonical: ${JSON.stringify(path)}`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
export function compileEvaluationEvidence(input) {
|
|
86
|
+
const { maximumBlockBytes } = input;
|
|
87
|
+
if (!Number.isSafeInteger(maximumBlockBytes) || maximumBlockBytes < 4) {
|
|
88
|
+
throw new Error("evidence block byte bound must be an integer of at least four");
|
|
89
|
+
}
|
|
90
|
+
const ordered = [...input.sources].sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
|
|
91
|
+
const paths = new Set();
|
|
92
|
+
return ordered.map((source) => {
|
|
93
|
+
assertSourcePath(source.path);
|
|
94
|
+
if (paths.has(source.path)) {
|
|
95
|
+
throw new Error(`duplicate evidence source path ${JSON.stringify(source.path)}`);
|
|
96
|
+
}
|
|
97
|
+
paths.add(source.path);
|
|
98
|
+
if (source.content.length === 0) {
|
|
99
|
+
throw new Error(`evidence source is empty: ${JSON.stringify(source.path)}`);
|
|
100
|
+
}
|
|
101
|
+
const sourceDigest = sha256(source.content);
|
|
102
|
+
const blocks = blockFragments(lineFragments(source.content, maximumBlockBytes), maximumBlockBytes).map((fragments, ordinal) => {
|
|
103
|
+
const first = fragments[0];
|
|
104
|
+
const last = fragments.at(-1);
|
|
105
|
+
const text = fragments.map((fragment) => fragment.text).join("");
|
|
106
|
+
return {
|
|
107
|
+
id: evidenceId({
|
|
108
|
+
path: source.path,
|
|
109
|
+
sourceDigest,
|
|
110
|
+
ordinal,
|
|
111
|
+
text
|
|
112
|
+
}),
|
|
113
|
+
path: source.path,
|
|
114
|
+
sourceDigest,
|
|
115
|
+
contentDigest: sha256(text),
|
|
116
|
+
ordinal,
|
|
117
|
+
startLine: first.line,
|
|
118
|
+
endLine: last.line,
|
|
119
|
+
text
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
path: source.path,
|
|
124
|
+
sourceDigest,
|
|
125
|
+
sourceBytes: bytes(source.content),
|
|
126
|
+
sourceBlockCount: blocks.length,
|
|
127
|
+
blocks
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const endingLine = (startLine, text) => {
|
|
132
|
+
const newlineCount = text.split("\n").length - 1;
|
|
133
|
+
return startLine + newlineCount - (text.endsWith("\n") ? 1 : 0);
|
|
134
|
+
};
|
|
135
|
+
export function assertEvaluationEvidenceSources(sources) {
|
|
136
|
+
const paths = new Set();
|
|
137
|
+
let previousPath;
|
|
138
|
+
for (const source of sources) {
|
|
139
|
+
assertSourcePath(source.path);
|
|
140
|
+
if (previousPath !== undefined && previousPath >= source.path) {
|
|
141
|
+
throw new Error("compiled evidence sources are not in canonical path order");
|
|
142
|
+
}
|
|
143
|
+
previousPath = source.path;
|
|
144
|
+
if (paths.has(source.path)) {
|
|
145
|
+
throw new Error(`duplicate evidence source path ${JSON.stringify(source.path)}`);
|
|
146
|
+
}
|
|
147
|
+
paths.add(source.path);
|
|
148
|
+
if (source.blocks.length === 0) {
|
|
149
|
+
throw new Error(`compiled evidence source has no blocks: ${JSON.stringify(source.path)}`);
|
|
150
|
+
}
|
|
151
|
+
if ((source.sourceBytes === undefined) !==
|
|
152
|
+
(source.sourceBlockCount === undefined)) {
|
|
153
|
+
throw new Error(`compiled evidence source has incomplete source metadata: ${JSON.stringify(source.path)}`);
|
|
154
|
+
}
|
|
155
|
+
if (source.sourceBytes !== undefined &&
|
|
156
|
+
(!Number.isSafeInteger(source.sourceBytes) || source.sourceBytes < 1)) {
|
|
157
|
+
throw new Error(`compiled evidence source byte metadata is invalid: ${JSON.stringify(source.path)}`);
|
|
158
|
+
}
|
|
159
|
+
if (source.sourceBlockCount !== undefined &&
|
|
160
|
+
(!Number.isSafeInteger(source.sourceBlockCount) ||
|
|
161
|
+
source.sourceBlockCount < source.blocks.length)) {
|
|
162
|
+
throw new Error(`compiled evidence source block metadata is invalid: ${JSON.stringify(source.path)}`);
|
|
163
|
+
}
|
|
164
|
+
const fullCoverage = source.sourceBlockCount === undefined ||
|
|
165
|
+
(source.sourceBlockCount === source.blocks.length &&
|
|
166
|
+
source.blocks.every((block, index) => block.ordinal === index));
|
|
167
|
+
if (fullCoverage) {
|
|
168
|
+
const reconstructed = source.blocks.map((block) => block.text).join("");
|
|
169
|
+
if (sha256(reconstructed) !== source.sourceDigest ||
|
|
170
|
+
(source.sourceBytes !== undefined &&
|
|
171
|
+
bytes(reconstructed) !== source.sourceBytes)) {
|
|
172
|
+
throw new Error(`compiled evidence source digest does not match ${JSON.stringify(source.path)}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
let currentLine = 1;
|
|
176
|
+
let previousOrdinal = -1;
|
|
177
|
+
let previousStartLine = 0;
|
|
178
|
+
for (const [index, block] of source.blocks.entries()) {
|
|
179
|
+
if (block.path !== source.path ||
|
|
180
|
+
block.sourceDigest !== source.sourceDigest ||
|
|
181
|
+
block.contentDigest !== sha256(block.text) ||
|
|
182
|
+
block.id !==
|
|
183
|
+
evidenceId({
|
|
184
|
+
path: source.path,
|
|
185
|
+
sourceDigest: source.sourceDigest,
|
|
186
|
+
ordinal: block.ordinal,
|
|
187
|
+
text: block.text
|
|
188
|
+
})) {
|
|
189
|
+
throw new Error(`compiled evidence block identity does not match ${JSON.stringify(block.id)}`);
|
|
190
|
+
}
|
|
191
|
+
const expectedStartLine = fullCoverage ? currentLine : block.startLine;
|
|
192
|
+
const expectedEndLine = endingLine(expectedStartLine, block.text);
|
|
193
|
+
if (block.startLine !== expectedStartLine ||
|
|
194
|
+
block.endLine !== expectedEndLine ||
|
|
195
|
+
block.ordinal <= previousOrdinal ||
|
|
196
|
+
block.startLine < previousStartLine ||
|
|
197
|
+
block.startLine < 1 ||
|
|
198
|
+
block.endLine < block.startLine ||
|
|
199
|
+
(source.sourceBlockCount !== undefined &&
|
|
200
|
+
block.ordinal >= source.sourceBlockCount)) {
|
|
201
|
+
throw new Error(`compiled evidence block line metadata does not match ${JSON.stringify(block.id)}`);
|
|
202
|
+
}
|
|
203
|
+
if (fullCoverage && block.ordinal !== index) {
|
|
204
|
+
throw new Error(`compiled evidence block ordinal does not match ${JSON.stringify(block.id)}`);
|
|
205
|
+
}
|
|
206
|
+
currentLine =
|
|
207
|
+
expectedEndLine + (block.text.endsWith("\n") ? 1 : 0);
|
|
208
|
+
previousOrdinal = block.ordinal;
|
|
209
|
+
previousStartLine = block.startLine;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export function selectEvaluationEvidenceBlocks(input) {
|
|
214
|
+
assertEvaluationEvidenceSources(input.sources);
|
|
215
|
+
const selectedIds = new Set(input.evidenceIds);
|
|
216
|
+
if (selectedIds.size !== input.evidenceIds.length) {
|
|
217
|
+
throw new Error("compiled evidence block selection contains duplicate ids");
|
|
218
|
+
}
|
|
219
|
+
const selected = input.sources
|
|
220
|
+
.map((source) => ({
|
|
221
|
+
...source,
|
|
222
|
+
blocks: source.blocks.filter((block) => selectedIds.delete(block.id))
|
|
223
|
+
}))
|
|
224
|
+
.filter((source) => source.blocks.length > 0);
|
|
225
|
+
if (selectedIds.size > 0) {
|
|
226
|
+
throw new Error(`compiled evidence block selection contains unknown ids: ${[
|
|
227
|
+
...selectedIds
|
|
228
|
+
].join(", ")}`);
|
|
229
|
+
}
|
|
230
|
+
assertEvaluationEvidenceSources(selected);
|
|
231
|
+
return selected;
|
|
232
|
+
}
|
|
233
|
+
export function mergeEvaluationEvidenceSources(packets) {
|
|
234
|
+
const byPath = new Map();
|
|
235
|
+
for (const packet of packets) {
|
|
236
|
+
assertEvaluationEvidenceSources(packet);
|
|
237
|
+
for (const source of packet) {
|
|
238
|
+
const existing = byPath.get(source.path);
|
|
239
|
+
if (existing === undefined) {
|
|
240
|
+
byPath.set(source.path, source);
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (existing.sourceDigest !== source.sourceDigest ||
|
|
244
|
+
existing.sourceBytes !== source.sourceBytes ||
|
|
245
|
+
existing.sourceBlockCount !== source.sourceBlockCount) {
|
|
246
|
+
throw new Error(`evidence source changed between authoring packets: ${JSON.stringify(source.path)}`);
|
|
247
|
+
}
|
|
248
|
+
const byOrdinal = new Map(existing.blocks.map((block) => [block.ordinal, block]));
|
|
249
|
+
for (const block of source.blocks) {
|
|
250
|
+
const current = byOrdinal.get(block.ordinal);
|
|
251
|
+
if (current !== undefined &&
|
|
252
|
+
JSON.stringify(current) !== JSON.stringify(block)) {
|
|
253
|
+
throw new Error(`evidence source block changed between authoring packets: ${JSON.stringify(block.id)}`);
|
|
254
|
+
}
|
|
255
|
+
byOrdinal.set(block.ordinal, block);
|
|
256
|
+
}
|
|
257
|
+
byPath.set(source.path, {
|
|
258
|
+
...existing,
|
|
259
|
+
blocks: [...byOrdinal.values()].sort((left, right) => left.ordinal - right.ordinal)
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const merged = [...byPath.values()].sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
|
|
264
|
+
assertEvaluationEvidenceSources(merged);
|
|
265
|
+
return merged;
|
|
266
|
+
}
|
|
267
|
+
const evidenceBlocksById = (sources) => {
|
|
268
|
+
assertEvaluationEvidenceSources(sources);
|
|
269
|
+
const byId = new Map();
|
|
270
|
+
for (const source of sources) {
|
|
271
|
+
for (const block of source.blocks) {
|
|
272
|
+
if (byId.has(block.id)) {
|
|
273
|
+
throw new Error(`duplicate compiled evidence id ${JSON.stringify(block.id)}`);
|
|
274
|
+
}
|
|
275
|
+
byId.set(block.id, block);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return byId;
|
|
279
|
+
};
|
|
280
|
+
export function resolveEvaluationEvidence(input) {
|
|
281
|
+
if (input.evidenceIds.length === 0) {
|
|
282
|
+
throw new Error("evaluation case must select at least one evidence block");
|
|
283
|
+
}
|
|
284
|
+
const { maximumContextBytes } = input;
|
|
285
|
+
if (!Number.isSafeInteger(maximumContextBytes) || maximumContextBytes < 1) {
|
|
286
|
+
throw new Error("evidence context byte bound must be a positive integer");
|
|
287
|
+
}
|
|
288
|
+
const byId = evidenceBlocksById(input.sources);
|
|
289
|
+
const selected = new Set();
|
|
290
|
+
let selectedBytes = 0;
|
|
291
|
+
return input.evidenceIds.map((id) => {
|
|
292
|
+
if (selected.has(id)) {
|
|
293
|
+
throw new Error(`evaluation case selects duplicate evidence id ${JSON.stringify(id)}`);
|
|
294
|
+
}
|
|
295
|
+
selected.add(id);
|
|
296
|
+
const block = byId.get(id);
|
|
297
|
+
if (block === undefined) {
|
|
298
|
+
throw new Error(`evaluation case selects unknown evidence id ${JSON.stringify(id)}`);
|
|
299
|
+
}
|
|
300
|
+
selectedBytes += bytes(block.text);
|
|
301
|
+
if (selectedBytes > maximumContextBytes) {
|
|
302
|
+
throw new Error(`evaluation case evidence exceeds the ${String(maximumContextBytes)} byte context bound`);
|
|
303
|
+
}
|
|
304
|
+
return block;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
export function renderEvaluationEvidenceContext(blocks) {
|
|
308
|
+
if (blocks.length === 0) {
|
|
309
|
+
throw new Error("evaluation context requires at least one resolved evidence block");
|
|
310
|
+
}
|
|
311
|
+
return blocks
|
|
312
|
+
.map((block) => [
|
|
313
|
+
`Evidence ${block.id} — ${block.path} (lines ${String(block.startLine)}-${String(block.endLine)})`,
|
|
314
|
+
"-----",
|
|
315
|
+
block.text,
|
|
316
|
+
"-----"
|
|
317
|
+
].join("\n"))
|
|
318
|
+
.join("\n\n");
|
|
319
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const EVAL_GRADER_CALIBRATION_POLICY_VERSION: 1;
|
|
3
|
+
export declare const EvalGraderCalibrationControl: Schema.Struct<{
|
|
4
|
+
readonly id: Schema.String;
|
|
5
|
+
readonly controlDigest: Schema.String;
|
|
6
|
+
readonly suiteKind: Schema.Literals<readonly ["dimension", "composition"]>;
|
|
7
|
+
readonly suiteId: Schema.String;
|
|
8
|
+
readonly caseId: Schema.String;
|
|
9
|
+
readonly authoredControlId: Schema.String;
|
|
10
|
+
readonly kind: Schema.Literals<readonly ["positive", "missing-criterion", "forbidden-behavior", "non-responsive"]>;
|
|
11
|
+
readonly targetedCriterionIds: Schema.$Array<Schema.String>;
|
|
12
|
+
readonly expectedOutcome: Schema.Literals<readonly ["accept", "reject"]>;
|
|
13
|
+
readonly prompt: Schema.String;
|
|
14
|
+
readonly criteria: Schema.String;
|
|
15
|
+
readonly response: Schema.String;
|
|
16
|
+
}>;
|
|
17
|
+
export type EvalGraderCalibrationControl = typeof EvalGraderCalibrationControl.Type;
|
|
18
|
+
export declare const EvalGraderCalibrationPlan: Schema.Struct<{
|
|
19
|
+
readonly version: Schema.Literal<1>;
|
|
20
|
+
readonly policyVersion: Schema.Literal<1>;
|
|
21
|
+
readonly evaluationDigest: Schema.String;
|
|
22
|
+
readonly judgeProtocolVersion: Schema.Literal<1>;
|
|
23
|
+
readonly judgeModel: Schema.String;
|
|
24
|
+
readonly judgeReasoningEffort: Schema.Null;
|
|
25
|
+
readonly judgeSystemPrompt: Schema.String;
|
|
26
|
+
readonly minimumJudgeScore: Schema.Finite;
|
|
27
|
+
readonly callCount: Schema.Finite;
|
|
28
|
+
readonly controls: Schema.$Array<Schema.Struct<{
|
|
29
|
+
readonly id: Schema.String;
|
|
30
|
+
readonly controlDigest: Schema.String;
|
|
31
|
+
readonly suiteKind: Schema.Literals<readonly ["dimension", "composition"]>;
|
|
32
|
+
readonly suiteId: Schema.String;
|
|
33
|
+
readonly caseId: Schema.String;
|
|
34
|
+
readonly authoredControlId: Schema.String;
|
|
35
|
+
readonly kind: Schema.Literals<readonly ["positive", "missing-criterion", "forbidden-behavior", "non-responsive"]>;
|
|
36
|
+
readonly targetedCriterionIds: Schema.$Array<Schema.String>;
|
|
37
|
+
readonly expectedOutcome: Schema.Literals<readonly ["accept", "reject"]>;
|
|
38
|
+
readonly prompt: Schema.String;
|
|
39
|
+
readonly criteria: Schema.String;
|
|
40
|
+
readonly response: Schema.String;
|
|
41
|
+
}>>;
|
|
42
|
+
readonly planDigest: Schema.String;
|
|
43
|
+
}>;
|
|
44
|
+
export type EvalGraderCalibrationPlan = typeof EvalGraderCalibrationPlan.Type;
|
|
45
|
+
export declare const EvalGraderCalibrationObservation: Schema.Struct<{
|
|
46
|
+
readonly controlId: Schema.String;
|
|
47
|
+
readonly judgeModel: Schema.String;
|
|
48
|
+
readonly callId: Schema.String;
|
|
49
|
+
readonly pass: Schema.Boolean;
|
|
50
|
+
readonly score: Schema.Finite;
|
|
51
|
+
readonly reason: Schema.String;
|
|
52
|
+
readonly costUsd: Schema.optionalKey<Schema.Finite>;
|
|
53
|
+
readonly durationMs: Schema.optionalKey<Schema.Finite>;
|
|
54
|
+
readonly inputTokens: Schema.optionalKey<Schema.Finite>;
|
|
55
|
+
readonly outputTokens: Schema.optionalKey<Schema.Finite>;
|
|
56
|
+
}>;
|
|
57
|
+
export type EvalGraderCalibrationObservation = typeof EvalGraderCalibrationObservation.Type;
|
|
58
|
+
export declare const EvalGraderCalibrationResult: Schema.Struct<{
|
|
59
|
+
readonly expectedOutcome: Schema.Literals<readonly ["accept", "reject"]>;
|
|
60
|
+
readonly observedOutcome: Schema.Literals<readonly ["accept", "reject"]>;
|
|
61
|
+
readonly matchedExpectation: Schema.Boolean;
|
|
62
|
+
readonly controlId: Schema.String;
|
|
63
|
+
readonly judgeModel: Schema.String;
|
|
64
|
+
readonly callId: Schema.String;
|
|
65
|
+
readonly pass: Schema.Boolean;
|
|
66
|
+
readonly score: Schema.Finite;
|
|
67
|
+
readonly reason: Schema.String;
|
|
68
|
+
readonly costUsd: Schema.optionalKey<Schema.Finite>;
|
|
69
|
+
readonly durationMs: Schema.optionalKey<Schema.Finite>;
|
|
70
|
+
readonly inputTokens: Schema.optionalKey<Schema.Finite>;
|
|
71
|
+
readonly outputTokens: Schema.optionalKey<Schema.Finite>;
|
|
72
|
+
}>;
|
|
73
|
+
export type EvalGraderCalibrationResult = typeof EvalGraderCalibrationResult.Type;
|
|
74
|
+
export declare const EvalGraderCalibrationReport: Schema.Struct<{
|
|
75
|
+
readonly version: Schema.Literal<1>;
|
|
76
|
+
readonly policyVersion: Schema.Literal<1>;
|
|
77
|
+
readonly planDigest: Schema.String;
|
|
78
|
+
readonly evaluationDigest: Schema.String;
|
|
79
|
+
readonly judgeProtocolVersion: Schema.Literal<1>;
|
|
80
|
+
readonly judgeModel: Schema.String;
|
|
81
|
+
readonly judgeReasoningEffort: Schema.Null;
|
|
82
|
+
readonly judgeSystemPrompt: Schema.String;
|
|
83
|
+
readonly minimumJudgeScore: Schema.Finite;
|
|
84
|
+
readonly startedAt: Schema.String;
|
|
85
|
+
readonly finishedAt: Schema.String;
|
|
86
|
+
readonly callCount: Schema.Finite;
|
|
87
|
+
readonly acceptedCount: Schema.Finite;
|
|
88
|
+
readonly rejectedCount: Schema.Finite;
|
|
89
|
+
readonly matchedCount: Schema.Finite;
|
|
90
|
+
readonly passed: Schema.Boolean;
|
|
91
|
+
readonly results: Schema.$Array<Schema.Struct<{
|
|
92
|
+
readonly expectedOutcome: Schema.Literals<readonly ["accept", "reject"]>;
|
|
93
|
+
readonly observedOutcome: Schema.Literals<readonly ["accept", "reject"]>;
|
|
94
|
+
readonly matchedExpectation: Schema.Boolean;
|
|
95
|
+
readonly controlId: Schema.String;
|
|
96
|
+
readonly judgeModel: Schema.String;
|
|
97
|
+
readonly callId: Schema.String;
|
|
98
|
+
readonly pass: Schema.Boolean;
|
|
99
|
+
readonly score: Schema.Finite;
|
|
100
|
+
readonly reason: Schema.String;
|
|
101
|
+
readonly costUsd: Schema.optionalKey<Schema.Finite>;
|
|
102
|
+
readonly durationMs: Schema.optionalKey<Schema.Finite>;
|
|
103
|
+
readonly inputTokens: Schema.optionalKey<Schema.Finite>;
|
|
104
|
+
readonly outputTokens: Schema.optionalKey<Schema.Finite>;
|
|
105
|
+
}>>;
|
|
106
|
+
readonly reportDigest: Schema.String;
|
|
107
|
+
}>;
|
|
108
|
+
export type EvalGraderCalibrationReport = typeof EvalGraderCalibrationReport.Type;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { EVAL_GRADER_JUDGE_PROTOCOL_VERSION } from "./evaluation-grading-policy.js";
|
|
3
|
+
export const EVAL_GRADER_CALIBRATION_POLICY_VERSION = 1;
|
|
4
|
+
const NonNegativeInteger = Schema.Finite.pipe(Schema.check(Schema.makeFilter((value) => value >= 0 && Number.isInteger(value)
|
|
5
|
+
? undefined
|
|
6
|
+
: "value must be a non-negative integer")));
|
|
7
|
+
const UnitInterval = Schema.Finite.pipe(Schema.check(Schema.makeFilter((value) => value >= 0 && value <= 1
|
|
8
|
+
? undefined
|
|
9
|
+
: "value must be between zero and one")));
|
|
10
|
+
const NonNegativeFinite = Schema.Finite.pipe(Schema.check(Schema.makeFilter((value) => value >= 0 ? undefined : "value must be non-negative")));
|
|
11
|
+
export const EvalGraderCalibrationControl = Schema.Struct({
|
|
12
|
+
id: Schema.String,
|
|
13
|
+
controlDigest: Schema.String,
|
|
14
|
+
suiteKind: Schema.Literals(["dimension", "composition"]),
|
|
15
|
+
suiteId: Schema.String,
|
|
16
|
+
caseId: Schema.String,
|
|
17
|
+
authoredControlId: Schema.String,
|
|
18
|
+
kind: Schema.Literals([
|
|
19
|
+
"positive",
|
|
20
|
+
"missing-criterion",
|
|
21
|
+
"forbidden-behavior",
|
|
22
|
+
"non-responsive"
|
|
23
|
+
]),
|
|
24
|
+
targetedCriterionIds: Schema.Array(Schema.String),
|
|
25
|
+
expectedOutcome: Schema.Literals(["accept", "reject"]),
|
|
26
|
+
prompt: Schema.String,
|
|
27
|
+
criteria: Schema.String,
|
|
28
|
+
response: Schema.String
|
|
29
|
+
});
|
|
30
|
+
export const EvalGraderCalibrationPlan = Schema.Struct({
|
|
31
|
+
version: Schema.Literal(1),
|
|
32
|
+
policyVersion: Schema.Literal(EVAL_GRADER_CALIBRATION_POLICY_VERSION),
|
|
33
|
+
evaluationDigest: Schema.String,
|
|
34
|
+
judgeProtocolVersion: Schema.Literal(EVAL_GRADER_JUDGE_PROTOCOL_VERSION),
|
|
35
|
+
judgeModel: Schema.String,
|
|
36
|
+
judgeReasoningEffort: Schema.Null,
|
|
37
|
+
judgeSystemPrompt: Schema.String,
|
|
38
|
+
minimumJudgeScore: UnitInterval,
|
|
39
|
+
callCount: NonNegativeInteger,
|
|
40
|
+
controls: Schema.Array(EvalGraderCalibrationControl),
|
|
41
|
+
planDigest: Schema.String
|
|
42
|
+
});
|
|
43
|
+
export const EvalGraderCalibrationObservation = Schema.Struct({
|
|
44
|
+
controlId: Schema.String,
|
|
45
|
+
judgeModel: Schema.String,
|
|
46
|
+
callId: Schema.String,
|
|
47
|
+
pass: Schema.Boolean,
|
|
48
|
+
score: UnitInterval,
|
|
49
|
+
reason: Schema.String,
|
|
50
|
+
costUsd: Schema.optionalKey(NonNegativeFinite),
|
|
51
|
+
durationMs: Schema.optionalKey(NonNegativeFinite),
|
|
52
|
+
inputTokens: Schema.optionalKey(NonNegativeInteger),
|
|
53
|
+
outputTokens: Schema.optionalKey(NonNegativeInteger)
|
|
54
|
+
});
|
|
55
|
+
export const EvalGraderCalibrationResult = Schema.Struct({
|
|
56
|
+
...EvalGraderCalibrationObservation.fields,
|
|
57
|
+
expectedOutcome: Schema.Literals(["accept", "reject"]),
|
|
58
|
+
observedOutcome: Schema.Literals(["accept", "reject"]),
|
|
59
|
+
matchedExpectation: Schema.Boolean
|
|
60
|
+
});
|
|
61
|
+
export const EvalGraderCalibrationReport = Schema.Struct({
|
|
62
|
+
version: Schema.Literal(1),
|
|
63
|
+
policyVersion: Schema.Literal(EVAL_GRADER_CALIBRATION_POLICY_VERSION),
|
|
64
|
+
planDigest: Schema.String,
|
|
65
|
+
evaluationDigest: Schema.String,
|
|
66
|
+
judgeProtocolVersion: Schema.Literal(EVAL_GRADER_JUDGE_PROTOCOL_VERSION),
|
|
67
|
+
judgeModel: Schema.String,
|
|
68
|
+
judgeReasoningEffort: Schema.Null,
|
|
69
|
+
judgeSystemPrompt: Schema.String,
|
|
70
|
+
minimumJudgeScore: UnitInterval,
|
|
71
|
+
startedAt: Schema.String,
|
|
72
|
+
finishedAt: Schema.String,
|
|
73
|
+
callCount: NonNegativeInteger,
|
|
74
|
+
acceptedCount: NonNegativeInteger,
|
|
75
|
+
rejectedCount: NonNegativeInteger,
|
|
76
|
+
matchedCount: NonNegativeInteger,
|
|
77
|
+
passed: Schema.Boolean,
|
|
78
|
+
results: Schema.Array(EvalGraderCalibrationResult),
|
|
79
|
+
reportDigest: Schema.String
|
|
80
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type EvalGraderCalibrationObservation as CalibrationObservation, type EvalGraderCalibrationPlan as CalibrationPlan, type EvalGraderCalibrationReport as CalibrationReport } from "./evaluation-grader-calibration-protocol.js";
|
|
2
|
+
import type { EvalEvaluationProposal } from "./project-contracts.js";
|
|
3
|
+
export { EVAL_GRADER_CALIBRATION_POLICY_VERSION, EvalGraderCalibrationControl, EvalGraderCalibrationObservation, EvalGraderCalibrationPlan, EvalGraderCalibrationReport, EvalGraderCalibrationResult } from "./evaluation-grader-calibration-protocol.js";
|
|
4
|
+
export declare const evaluationGraderCalibrationReportDigest: (report: Omit<CalibrationReport, "reportDigest">) => string;
|
|
5
|
+
export declare function compileEvaluationGraderCalibrationPlan(input: {
|
|
6
|
+
readonly proposal: EvalEvaluationProposal;
|
|
7
|
+
readonly sourceInventory: readonly string[];
|
|
8
|
+
}): CalibrationPlan;
|
|
9
|
+
export declare function compileEvaluationGraderCalibrationReport(input: {
|
|
10
|
+
readonly plan: CalibrationPlan;
|
|
11
|
+
readonly startedAt: string;
|
|
12
|
+
readonly finishedAt: string;
|
|
13
|
+
readonly observations: readonly CalibrationObservation[];
|
|
14
|
+
}): CalibrationReport;
|
|
15
|
+
export declare function assertEvaluationGraderCalibrationPassed(input: {
|
|
16
|
+
readonly plan: CalibrationPlan;
|
|
17
|
+
readonly report: CalibrationReport;
|
|
18
|
+
}): void;
|