@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,688 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { test } from "node:test";
|
|
4
|
+
import { Deferred, Effect, Fiber, Layer, Schema } from "effect";
|
|
5
|
+
import { EvalProjectAuthoringError, RepositoryFoundryError } from "../errors.js";
|
|
6
|
+
import { EvalAuthoringTransport } from "../project-authoring.js";
|
|
7
|
+
import { repositoryFoundryModelPlanV1 } from "../repository-language-model-protocol.js";
|
|
8
|
+
import { assertRepositorySemanticCalibrationPlanV1, assertRepositorySemanticCalibrationReportV1, compileRepositorySemanticCalibrationPlanV1, compileRepositorySemanticCalibrationReportV1, executeRepositorySemanticCalibrationPlanV1, repositorySemanticCalibrationExampleDigestV1, repositorySemanticCalibrationInputDigestV1 } from "../repository-semantic-calibration.js";
|
|
9
|
+
import { executeRepositorySemanticReviewV1, prepareRepositorySemanticReviewV1 } from "../services/case-generation/service.js";
|
|
10
|
+
import { RepositoryFoundryProgressLive } from "../services/foundry-progress/service.js";
|
|
11
|
+
import { RepositoryFoundryLanguageModelLive } from "../services/language-model/service.js";
|
|
12
|
+
const hash = (text) => createHash("sha256").update(text).digest("hex");
|
|
13
|
+
const copy = (value) => JSON.parse(JSON.stringify(value));
|
|
14
|
+
const modelPlan = repositoryFoundryModelPlanV1({
|
|
15
|
+
primaryModel: "openai/gpt-6-astra",
|
|
16
|
+
criticBModel: "openai/gpt-5.6-terra"
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Synthetic protocol-test data only. The checker stdout below is deliberately
|
|
20
|
+
* supplied test data, NOT evidence of a live independent development campaign.
|
|
21
|
+
*/
|
|
22
|
+
const fixture = (citationSource) => {
|
|
23
|
+
const source = { path: "src/clamp.js", content: "export const clamp = (value) => value;\n" };
|
|
24
|
+
const supportingSource = {
|
|
25
|
+
path: "src/clamp-finite.js",
|
|
26
|
+
content: "export const clampFinite = (value) => Math.min(10, Math.max(0, value));\n"
|
|
27
|
+
};
|
|
28
|
+
const supportingSourceProvided = citationSource !== undefined && citationSource !== "unprovided";
|
|
29
|
+
const input = {
|
|
30
|
+
requestedDimension: "numeric boundary preservation",
|
|
31
|
+
repositoryEnvironment: {
|
|
32
|
+
commit: "a".repeat(40),
|
|
33
|
+
sources: citationSource === "repository" ? [supportingSource] : [],
|
|
34
|
+
localImports: {
|
|
35
|
+
commit: "a".repeat(40),
|
|
36
|
+
sources: citationSource === "local-import" ? [supportingSource] : [],
|
|
37
|
+
omitted: [],
|
|
38
|
+
unresolved: []
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
visible: {
|
|
42
|
+
lane: "repository-agent",
|
|
43
|
+
id: "visible-clamp",
|
|
44
|
+
requestText: "Clamp finite values into [0,10] and preserve fractional values inside the interval.",
|
|
45
|
+
checkoutCommit: "a".repeat(40),
|
|
46
|
+
allowedTools: ["read", "edit", "test"],
|
|
47
|
+
constraints: ["Preserve the exported clamp function."]
|
|
48
|
+
},
|
|
49
|
+
targetBehavior: [
|
|
50
|
+
{ id: "lower", description: "Negative values become zero.", critical: true, evidence: [] },
|
|
51
|
+
{ id: "upper", description: "Values above ten become ten.", critical: true, evidence: [] },
|
|
52
|
+
{
|
|
53
|
+
id: "preserve",
|
|
54
|
+
description: "In-range values remain unchanged.",
|
|
55
|
+
critical: true,
|
|
56
|
+
evidence: []
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
preChangeSources: [
|
|
60
|
+
source,
|
|
61
|
+
...(citationSource === "pre-change" ? [supportingSource] : [])
|
|
62
|
+
],
|
|
63
|
+
solutions: [
|
|
64
|
+
{
|
|
65
|
+
id: "control-a",
|
|
66
|
+
family: "comparison-left",
|
|
67
|
+
fileOverrides: [
|
|
68
|
+
{
|
|
69
|
+
path: source.path,
|
|
70
|
+
content: citationSource === undefined
|
|
71
|
+
? "export const clamp = (value) => Math.min(10, Math.max(0, value));\n"
|
|
72
|
+
: 'import { clampFinite } from "./clamp-finite.js";\n' +
|
|
73
|
+
"export const clamp = (value) => clampFinite(value);\n"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "control-b",
|
|
79
|
+
family: "comparison-right",
|
|
80
|
+
fileOverrides: [
|
|
81
|
+
{
|
|
82
|
+
path: source.path,
|
|
83
|
+
content: citationSource === undefined
|
|
84
|
+
? "export const clamp = (value) => Math.max(0, Math.min(10, value));\n"
|
|
85
|
+
: 'import { clampFinite } from "./clamp-finite.js";\n' +
|
|
86
|
+
"export function clamp(value) { return clampFinite(value); }\n"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "control-c",
|
|
92
|
+
family: "other",
|
|
93
|
+
fileOverrides: [
|
|
94
|
+
{ path: source.path, content: "export const clamp = (value) => Math.min(10, value);\n" }
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
comparisonSolutionIds: ["control-a", "control-b"]
|
|
99
|
+
};
|
|
100
|
+
const labels = [
|
|
101
|
+
{
|
|
102
|
+
solutionId: "control-a",
|
|
103
|
+
expectedClass: "valid",
|
|
104
|
+
rationale: "PRIVATE_LABEL_RATIONALE: exact finite clamp identity.",
|
|
105
|
+
violatedBehaviorIds: [],
|
|
106
|
+
evidenceIds: ["check-transcript"]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
solutionId: "control-b",
|
|
110
|
+
expectedClass: "valid",
|
|
111
|
+
rationale: "PRIVATE_LABEL_RATIONALE: equivalent complete finite clamp identity.",
|
|
112
|
+
violatedBehaviorIds: [],
|
|
113
|
+
evidenceIds: ["check-transcript"]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
solutionId: "control-c",
|
|
117
|
+
expectedClass: "wrong",
|
|
118
|
+
rationale: "PRIVATE_LABEL_RATIONALE: negative finite inputs remain negative.",
|
|
119
|
+
violatedBehaviorIds: ["lower"],
|
|
120
|
+
evidenceIds: ["check-transcript"]
|
|
121
|
+
}
|
|
122
|
+
];
|
|
123
|
+
const checkerSource = "// SYNTHETIC_CHECKER_SOURCE_FOR_PROTOCOL_TESTS_ONLY\n";
|
|
124
|
+
const transcript = JSON.stringify({
|
|
125
|
+
version: 1,
|
|
126
|
+
purpose: "development-label-adjudication",
|
|
127
|
+
inputDigest: repositorySemanticCalibrationInputDigestV1(input),
|
|
128
|
+
checkerId: "synthetic-independent-checker",
|
|
129
|
+
checkerSourceDigest: hash(checkerSource),
|
|
130
|
+
checks: labels.map((label) => ({
|
|
131
|
+
solutionId: label.solutionId,
|
|
132
|
+
classification: label.expectedClass,
|
|
133
|
+
repetitions: 2,
|
|
134
|
+
confirmed: true,
|
|
135
|
+
violatedBehaviorIds: label.violatedBehaviorIds
|
|
136
|
+
}))
|
|
137
|
+
});
|
|
138
|
+
const body = {
|
|
139
|
+
id: "clamp-development",
|
|
140
|
+
split: "development",
|
|
141
|
+
repository: {
|
|
142
|
+
id: "synthetic-protocol-test-repository",
|
|
143
|
+
commit: "a".repeat(40),
|
|
144
|
+
sourceDigests: [source, ...(supportingSourceProvided ? [supportingSource] : [])].map((entry) => ({ path: entry.path, sha256: hash(entry.content) }))
|
|
145
|
+
},
|
|
146
|
+
input,
|
|
147
|
+
adjudication: {
|
|
148
|
+
kind: "independent-executable-development-adjudication",
|
|
149
|
+
reservation: "not-reserved-holdout",
|
|
150
|
+
adjudicatorIds: ["synthetic-independent-checker"],
|
|
151
|
+
generatorIdentities: ["synthetic-control-author"],
|
|
152
|
+
completedAt: "2026-09-08T00:00:00.000Z",
|
|
153
|
+
inputDigest: repositorySemanticCalibrationInputDigestV1(input),
|
|
154
|
+
evidence: [
|
|
155
|
+
{
|
|
156
|
+
id: "check-transcript",
|
|
157
|
+
kind: "executable-development-check",
|
|
158
|
+
checkerSource,
|
|
159
|
+
checkerSourceSha256: hash(checkerSource),
|
|
160
|
+
content: transcript,
|
|
161
|
+
sha256: hash(transcript)
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
labels
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const example = { ...body, exampleDigest: repositorySemanticCalibrationExampleDigestV1(body) };
|
|
168
|
+
const manifest = {
|
|
169
|
+
version: 1,
|
|
170
|
+
purpose: "development-semantic-calibration",
|
|
171
|
+
thresholds: {
|
|
172
|
+
minimumScenarios: 1,
|
|
173
|
+
minimumValidControls: 2,
|
|
174
|
+
minimumWrongControls: 1,
|
|
175
|
+
maximumFalseValidRate: 0,
|
|
176
|
+
maximumFalseWrongRate: 0,
|
|
177
|
+
maximumUncertaintyRate: 0,
|
|
178
|
+
maximumInstabilityRate: 0,
|
|
179
|
+
requireCompleteExecution: true
|
|
180
|
+
},
|
|
181
|
+
examples: [example]
|
|
182
|
+
};
|
|
183
|
+
return { input, example, manifest };
|
|
184
|
+
};
|
|
185
|
+
const compile = (manifest = fixture().manifest, validControlReviewVersion = 2, repetitions = 3) => compileRepositorySemanticCalibrationPlanV1({
|
|
186
|
+
manifest,
|
|
187
|
+
modelPlan,
|
|
188
|
+
validControlReviewVersion,
|
|
189
|
+
repetitions
|
|
190
|
+
});
|
|
191
|
+
const response = (request) => ({
|
|
192
|
+
reviews: [
|
|
193
|
+
{
|
|
194
|
+
solutionId: "control-a",
|
|
195
|
+
classification: "valid",
|
|
196
|
+
detail: "PRIVATE_CRITIC_RATIONALE: the lower and upper requirements are implemented.",
|
|
197
|
+
violatedBehaviorIds: []
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
solutionId: "control-b",
|
|
201
|
+
classification: "valid",
|
|
202
|
+
detail: "PRIVATE_CRITIC_RATIONALE: the equivalent guard preserves finite values.",
|
|
203
|
+
violatedBehaviorIds: []
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
solutionId: "control-c",
|
|
207
|
+
classification: "wrong",
|
|
208
|
+
detail: "PRIVATE_CRITIC_RATIONALE: negative values violate the lower bound.",
|
|
209
|
+
violatedBehaviorIds: ["lower"]
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
...(request.schemaName === "routekit_repository_solution_review_v1"
|
|
213
|
+
? {}
|
|
214
|
+
: {
|
|
215
|
+
implementationIndependence: {
|
|
216
|
+
outcome: "correlated",
|
|
217
|
+
detail: "Both controls implement the same complete behavioral clamp.",
|
|
218
|
+
implementations: ["control-a", "control-b"].map((solutionId) => ({
|
|
219
|
+
solutionId,
|
|
220
|
+
mechanism: "finite lower/upper clamp",
|
|
221
|
+
sourcePaths: ["src/clamp.js"]
|
|
222
|
+
})),
|
|
223
|
+
correlatedFeatures: ["same-behavioral-mechanism"]
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
});
|
|
227
|
+
const transportFixture = (reply = (request, ordinal) => Effect.succeed({
|
|
228
|
+
text: JSON.stringify(response(request)),
|
|
229
|
+
callId: `synthetic-call-${String(ordinal)}`
|
|
230
|
+
})) => {
|
|
231
|
+
const calls = [];
|
|
232
|
+
const completeDetailed = (request) => Effect.suspend(() => {
|
|
233
|
+
calls.push(request);
|
|
234
|
+
return reply(request, calls.length);
|
|
235
|
+
});
|
|
236
|
+
const transport = Layer.succeed(EvalAuthoringTransport, EvalAuthoringTransport.of({
|
|
237
|
+
completeDetailed,
|
|
238
|
+
complete: (request) => completeDetailed(request).pipe(Effect.map((result) => result.text))
|
|
239
|
+
}));
|
|
240
|
+
return { calls, layer: RepositoryFoundryLanguageModelLive.pipe(Layer.provide(transport)) };
|
|
241
|
+
};
|
|
242
|
+
test("semantic calibration freezes source, independent check, policy, model, threshold and repetition identities", () => {
|
|
243
|
+
const original = fixture();
|
|
244
|
+
const first = compile(original.manifest);
|
|
245
|
+
assertRepositorySemanticCalibrationPlanV1(first);
|
|
246
|
+
assert.deepEqual(first, compile(original.manifest));
|
|
247
|
+
assert.equal(first.callCount, 6);
|
|
248
|
+
assert.equal(first.maximumOutputTokensPerCall, 32768);
|
|
249
|
+
assert.equal(first.requiredTotalOutputTokens, 6 * 32768);
|
|
250
|
+
assert.equal(first.admissionCredit, false);
|
|
251
|
+
assert.equal(Object.isFrozen(first.manifest.examples[0].input.solutions), true);
|
|
252
|
+
const changed = copy(original.manifest);
|
|
253
|
+
changed.thresholds.maximumUncertaintyRate = 0.1;
|
|
254
|
+
assert.notEqual(compile(changed).planDigest, first.planDigest);
|
|
255
|
+
assert.notEqual(compile(original.manifest, 1).planDigest, first.planDigest);
|
|
256
|
+
assert.notEqual(compile(original.manifest, 2, 2).planDigest, first.planDigest);
|
|
257
|
+
assert.equal(first.manifest.thresholds.maximumUncertaintyRate, 0);
|
|
258
|
+
const changedModel = compileRepositorySemanticCalibrationPlanV1({
|
|
259
|
+
manifest: original.manifest,
|
|
260
|
+
repetitions: 3,
|
|
261
|
+
validControlReviewVersion: 2,
|
|
262
|
+
modelPlan: repositoryFoundryModelPlanV1({ primaryModel: "openai/gpt-5.6-terra" })
|
|
263
|
+
});
|
|
264
|
+
assert.notEqual(changedModel.planDigest, first.planDigest);
|
|
265
|
+
const forged = copy(first);
|
|
266
|
+
forged.preparedCritics[0].instructionsDigest = "f".repeat(64);
|
|
267
|
+
assert.throws(() => assertRepositorySemanticCalibrationPlanV1(forged), /stale/u);
|
|
268
|
+
});
|
|
269
|
+
for (const scenario of [
|
|
270
|
+
{ source: "repository", version: 2, contextOnly: false, accepted: true },
|
|
271
|
+
{ source: "local-import", version: 2, contextOnly: false, accepted: true },
|
|
272
|
+
{ source: "pre-change", version: 2, contextOnly: false, accepted: true },
|
|
273
|
+
{ source: "unprovided", version: 2, contextOnly: false, accepted: false },
|
|
274
|
+
{ source: "local-import", version: 2, contextOnly: true, accepted: false },
|
|
275
|
+
{ source: "local-import", version: 1, contextOnly: false, accepted: false }
|
|
276
|
+
]) {
|
|
277
|
+
test(`critic source citations require supplied bytes and a changed-file anchor: ${scenario.source}, v${String(scenario.version)}, context-only=${String(scenario.contextOnly)}`, async () => {
|
|
278
|
+
const plan = compile(fixture(scenario.source).manifest, scenario.version, 2);
|
|
279
|
+
const transport = transportFixture((request, ordinal) => {
|
|
280
|
+
const value = copy(response(request));
|
|
281
|
+
for (const implementation of value.implementationIndependence.implementations) {
|
|
282
|
+
implementation.sourcePaths = [
|
|
283
|
+
...(scenario.contextOnly ? [] : ["src/clamp.js"]),
|
|
284
|
+
"src/clamp-finite.js"
|
|
285
|
+
];
|
|
286
|
+
}
|
|
287
|
+
return Effect.succeed({
|
|
288
|
+
text: JSON.stringify(value),
|
|
289
|
+
callId: `source-citation-${String(ordinal)}`
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
const report = await Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
293
|
+
plan,
|
|
294
|
+
operationId: `source-citation-${scenario.source}-${String(scenario.version)}`
|
|
295
|
+
}).pipe(Effect.provide(transport.layer)));
|
|
296
|
+
assert.equal(transport.calls.length, 4);
|
|
297
|
+
assert.equal(report.counts.executionFailureCalls, 0);
|
|
298
|
+
if (scenario.accepted) {
|
|
299
|
+
assert.equal(report.counts.malformedCalls, 0);
|
|
300
|
+
assert.equal(report.counts.validAsValid, 8);
|
|
301
|
+
assert.equal(report.counts.wrongAsWrong, 4);
|
|
302
|
+
assert.equal(report.counts.unscoredControls, 0);
|
|
303
|
+
assert.equal(report.counts.independenceCorrelated, 4);
|
|
304
|
+
assert.ok(report.observations.every((entry) => entry.outcome.kind === "classified"));
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
assert.equal(report.counts.malformedCalls, 4);
|
|
308
|
+
assert.equal(report.counts.unscoredControls, 12);
|
|
309
|
+
assert.ok(report.observations.every((entry) => entry.outcome.kind === "malformed" && entry.outcome.reason === "independence-review"));
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
for (const defect of [
|
|
314
|
+
"held-out",
|
|
315
|
+
"source-digest",
|
|
316
|
+
"checker-source",
|
|
317
|
+
"check-transcript",
|
|
318
|
+
"unconfirmed-label",
|
|
319
|
+
"unrepeated-check",
|
|
320
|
+
"human-without-evidence",
|
|
321
|
+
"self-adjudication",
|
|
322
|
+
"stale-input",
|
|
323
|
+
"unknown-model-field",
|
|
324
|
+
"undersized-population"
|
|
325
|
+
]) {
|
|
326
|
+
test(`semantic calibration rejects ${defect} before any model request`, () => {
|
|
327
|
+
const manifest = copy(fixture().manifest);
|
|
328
|
+
const example = manifest.examples[0];
|
|
329
|
+
if (defect === "held-out")
|
|
330
|
+
Object.assign(example, { split: "held-out" });
|
|
331
|
+
if (defect === "source-digest")
|
|
332
|
+
example.repository.sourceDigests[0].sha256 = "f".repeat(64);
|
|
333
|
+
const evidence = example.adjudication.evidence[0];
|
|
334
|
+
assert.equal(evidence.kind, "executable-development-check");
|
|
335
|
+
if (defect === "checker-source" && evidence.kind === "executable-development-check")
|
|
336
|
+
evidence.checkerSource += "tampered";
|
|
337
|
+
if (defect === "check-transcript")
|
|
338
|
+
evidence.sha256 = "f".repeat(64);
|
|
339
|
+
if (defect === "unconfirmed-label" || defect === "unrepeated-check") {
|
|
340
|
+
const check = JSON.parse(evidence.content);
|
|
341
|
+
if (defect === "unconfirmed-label")
|
|
342
|
+
check.checks[2].classification = "valid";
|
|
343
|
+
else
|
|
344
|
+
check.checks[0].repetitions = 1;
|
|
345
|
+
evidence.content = JSON.stringify(check);
|
|
346
|
+
evidence.sha256 = hash(evidence.content);
|
|
347
|
+
}
|
|
348
|
+
if (defect === "human-without-evidence")
|
|
349
|
+
example.adjudication.kind = "independent-human-development-adjudication";
|
|
350
|
+
if (defect === "self-adjudication")
|
|
351
|
+
example.adjudication.generatorIdentities.push(example.adjudication.adjudicatorIds[0]);
|
|
352
|
+
if (defect === "stale-input")
|
|
353
|
+
example.input.visible.id = "changed-visible-id";
|
|
354
|
+
if (defect === "unknown-model-field")
|
|
355
|
+
Object.assign(example.input, { expectedLabels: example.adjudication.labels });
|
|
356
|
+
if (defect === "undersized-population")
|
|
357
|
+
manifest.thresholds.minimumScenarios = 2;
|
|
358
|
+
example.exampleDigest = repositorySemanticCalibrationExampleDigestV1(example);
|
|
359
|
+
assert.throws(() => compile(manifest));
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
for (const version of [null, 1, 2]) {
|
|
363
|
+
test(`shared production critic preparation and execution is used for policy ${String(version)}`, async () => {
|
|
364
|
+
const { input } = fixture();
|
|
365
|
+
const prepared = prepareRepositorySemanticReviewV1({
|
|
366
|
+
role: "solution-critic-a",
|
|
367
|
+
modelContext: {
|
|
368
|
+
requestedDimension: input.requestedDimension,
|
|
369
|
+
repositoryEnvironment: input.repositoryEnvironment
|
|
370
|
+
},
|
|
371
|
+
visible: input.visible,
|
|
372
|
+
targetBehavior: input.targetBehavior,
|
|
373
|
+
preChangeSources: input.preChangeSources,
|
|
374
|
+
solutions: input.solutions.map((solution) => ({
|
|
375
|
+
...solution,
|
|
376
|
+
expectedClass: "DO_NOT_SEND",
|
|
377
|
+
privateFixture: "DO_NOT_SEND"
|
|
378
|
+
})),
|
|
379
|
+
comparisonSolutionIds: input.comparisonSolutionIds,
|
|
380
|
+
...(version === null ? {} : { validControlReviewVersion: version })
|
|
381
|
+
});
|
|
382
|
+
assert.equal(JSON.stringify(prepared.input).includes("DO_NOT_SEND"), false);
|
|
383
|
+
assert.equal(prepared.maximumOutputTokens, 32768);
|
|
384
|
+
assert.equal(prepared.instructions.includes("policy version 2"), version === 2);
|
|
385
|
+
assert.equal("implementationComparison" in prepared.input, version !== null);
|
|
386
|
+
const transport = transportFixture();
|
|
387
|
+
const result = await Effect.runPromise(executeRepositorySemanticReviewV1({
|
|
388
|
+
modelPlan,
|
|
389
|
+
operationId: "shared-critic-test",
|
|
390
|
+
prepared
|
|
391
|
+
}).pipe(Effect.provide(transport.layer)));
|
|
392
|
+
assert.equal(result.call.role, "solution-critic-a");
|
|
393
|
+
assert.equal(transport.calls.length, 1);
|
|
394
|
+
assert.equal(transport.calls[0].input, JSON.stringify(prepared.input));
|
|
395
|
+
assert.equal(transport.calls[0].instructions, prepared.instructions);
|
|
396
|
+
assert.equal(transport.calls[0].schemaName, prepared.schemaName);
|
|
397
|
+
assert.equal(Schema.decodeUnknownSync(prepared.outputSchema)(result.value).reviews.length, 3);
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
test("calibration runs both real critic paths without adjudication leakage or admission credit", async () => {
|
|
401
|
+
const plan = compile();
|
|
402
|
+
const transport = transportFixture();
|
|
403
|
+
const persisted = [];
|
|
404
|
+
const report = await Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
405
|
+
plan,
|
|
406
|
+
operationId: "development-calibration",
|
|
407
|
+
recordObservation: (observation) => Effect.sync(() => {
|
|
408
|
+
persisted.push(observation);
|
|
409
|
+
})
|
|
410
|
+
}).pipe(Effect.provide(transport.layer)));
|
|
411
|
+
assert.equal(transport.calls.length, 6);
|
|
412
|
+
assert.equal(persisted.length, 6);
|
|
413
|
+
assert.equal(report.observations.length, 6);
|
|
414
|
+
assert.deepEqual(new Set(transport.calls.map((call) => call.foundryRole)), new Set(["solution-critic-a", "solution-critic-b"]));
|
|
415
|
+
for (const call of transport.calls) {
|
|
416
|
+
assert.equal(/PRIVATE_LABEL_RATIONALE|SYNTHETIC_CHECKER_SOURCE|expectedClass|adjudication/u.test(call.input), false);
|
|
417
|
+
const binding = plan.preparedCritics.find((critic) => critic.role === call.foundryRole);
|
|
418
|
+
assert.equal(hash(call.input), binding.inputDigest);
|
|
419
|
+
assert.equal(hash(call.instructions), binding.instructionsDigest);
|
|
420
|
+
}
|
|
421
|
+
assert.deepEqual(report.denominators, {
|
|
422
|
+
scenarios: 1,
|
|
423
|
+
models: 2,
|
|
424
|
+
critics: 2,
|
|
425
|
+
repetitions: 3,
|
|
426
|
+
distinctControls: 3,
|
|
427
|
+
distinctValidControls: 2,
|
|
428
|
+
distinctWrongControls: 1,
|
|
429
|
+
scheduledCalls: 6,
|
|
430
|
+
scheduledControlClassifications: 18,
|
|
431
|
+
scheduledValidClassifications: 12,
|
|
432
|
+
scheduledWrongClassifications: 6
|
|
433
|
+
});
|
|
434
|
+
assert.equal(report.counts.validAsValid, 12);
|
|
435
|
+
assert.equal(report.counts.wrongAsWrong, 6);
|
|
436
|
+
assert.equal(report.counts.independenceCorrelated, 6);
|
|
437
|
+
assert.equal(report.counts.stableClassificationGroups, 6);
|
|
438
|
+
assert.equal(report.admissionCredit, false);
|
|
439
|
+
assert.equal(report.coverage.mechanismIndependence, "unadjudicated");
|
|
440
|
+
assert.equal(report.coverage.fullValidControlAcceptance, "not-established");
|
|
441
|
+
assert.equal("passed" in report, false);
|
|
442
|
+
assert.equal(/PRIVATE_LABEL_RATIONALE|PRIVATE_CRITIC_RATIONALE|export const clamp/u.test(JSON.stringify(report)), false);
|
|
443
|
+
assert.equal(report.controls.length, 3);
|
|
444
|
+
assert.ok(report.controls.every((control) => /^[a-f0-9]{64}$/u.test(control.controlDigest)));
|
|
445
|
+
assertRepositorySemanticCalibrationReportV1({ plan, report });
|
|
446
|
+
});
|
|
447
|
+
test("confusion, uncertainty, and label instability retain exact per-control observations", async () => {
|
|
448
|
+
const plan = compile();
|
|
449
|
+
const transport = transportFixture((request, ordinal) => {
|
|
450
|
+
const value = copy(response(request));
|
|
451
|
+
if (request.foundryRole === "solution-critic-a" && request.operationId.includes(":repeat-1:")) {
|
|
452
|
+
value.reviews[0].classification = "wrong";
|
|
453
|
+
value.reviews[0].violatedBehaviorIds = ["lower"];
|
|
454
|
+
}
|
|
455
|
+
if (request.foundryRole === "solution-critic-a" && request.operationId.includes(":repeat-2:"))
|
|
456
|
+
value.reviews[1].classification = "uncertain";
|
|
457
|
+
if (request.foundryRole === "solution-critic-b" && request.operationId.includes(":repeat-3:")) {
|
|
458
|
+
value.reviews[2].classification = "valid";
|
|
459
|
+
value.reviews[2].violatedBehaviorIds = [];
|
|
460
|
+
}
|
|
461
|
+
return Effect.succeed({ text: JSON.stringify(value), callId: `confusion-${String(ordinal)}` });
|
|
462
|
+
});
|
|
463
|
+
const report = await Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
464
|
+
plan,
|
|
465
|
+
operationId: "confusion-calibration"
|
|
466
|
+
}).pipe(Effect.provide(transport.layer)));
|
|
467
|
+
assert.equal(report.counts.validAsValid, 10);
|
|
468
|
+
assert.equal(report.counts.validAsWrong, 1);
|
|
469
|
+
assert.equal(report.counts.validAsUncertain, 1);
|
|
470
|
+
assert.equal(report.counts.wrongAsValid, 1);
|
|
471
|
+
assert.equal(report.counts.wrongAsWrong, 5);
|
|
472
|
+
assert.equal(report.counts.changedClassificationGroups, 3);
|
|
473
|
+
assert.equal(report.counts.stableClassificationGroups, 3);
|
|
474
|
+
assert.equal(report.counts.malformedCalls, 0);
|
|
475
|
+
assert.equal(report.counts.unscoredControls, 0);
|
|
476
|
+
assert.equal(report.observations[0].outcome.kind, "classified");
|
|
477
|
+
assert.deepEqual(report.thresholds, plan.manifest.thresholds);
|
|
478
|
+
assert.equal("passed" in report, false, "failed declared thresholds must not become a fake pass");
|
|
479
|
+
});
|
|
480
|
+
for (const defect of [
|
|
481
|
+
"invalid-json",
|
|
482
|
+
"schema",
|
|
483
|
+
"review-population",
|
|
484
|
+
"behavior-reference",
|
|
485
|
+
"independence-review"
|
|
486
|
+
]) {
|
|
487
|
+
test(`malformed ${defect} is counted separately from model execution failure`, async () => {
|
|
488
|
+
const plan = compile();
|
|
489
|
+
const transport = transportFixture((request, ordinal) => {
|
|
490
|
+
const value = copy(response(request));
|
|
491
|
+
if (defect === "schema")
|
|
492
|
+
Object.assign(value.reviews[0], { classification: "maybe" });
|
|
493
|
+
if (defect === "review-population")
|
|
494
|
+
value.reviews[2].solutionId = "control-a";
|
|
495
|
+
if (defect === "behavior-reference")
|
|
496
|
+
value.reviews[2].violatedBehaviorIds = ["invented"];
|
|
497
|
+
if (defect === "independence-review")
|
|
498
|
+
value.implementationIndependence.correlatedFeatures.push("same-behavioral-mechanism");
|
|
499
|
+
return Effect.succeed({
|
|
500
|
+
text: defect === "invalid-json" ? "not-json" : JSON.stringify(value),
|
|
501
|
+
callId: `malformed-${String(ordinal)}`
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
const report = await Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
505
|
+
plan,
|
|
506
|
+
operationId: "malformed-calibration"
|
|
507
|
+
}).pipe(Effect.provide(transport.layer)));
|
|
508
|
+
assert.equal(transport.calls.length, 6);
|
|
509
|
+
assert.equal(report.counts.malformedCalls, 6);
|
|
510
|
+
assert.equal(report.counts.executionFailureCalls, 0);
|
|
511
|
+
assert.equal(report.counts.unscoredControls, 18);
|
|
512
|
+
assert.equal(report.counts.incompleteClassificationGroups, 6);
|
|
513
|
+
assert.ok(report.observations.every((entry) => entry.outcome.kind === "malformed" && entry.outcome.reason === defect));
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
test("an execution failure settles its started pair, then records every remaining call as not-run", async () => {
|
|
517
|
+
const plan = compile();
|
|
518
|
+
const transport = transportFixture((request, ordinal) => request.foundryRole === "solution-critic-a"
|
|
519
|
+
? Effect.fail(new EvalProjectAuthoringError({
|
|
520
|
+
operation: "authoring-evaluations",
|
|
521
|
+
detail: "not-json in transport error prose must NOT classify this as malformed"
|
|
522
|
+
}))
|
|
523
|
+
: Effect.succeed({
|
|
524
|
+
text: JSON.stringify(response(request)),
|
|
525
|
+
callId: `settled-${String(ordinal)}`
|
|
526
|
+
}));
|
|
527
|
+
const persisted = [];
|
|
528
|
+
const report = await Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
529
|
+
plan,
|
|
530
|
+
operationId: "failed-calibration",
|
|
531
|
+
recordObservation: (observation) => Effect.sync(() => {
|
|
532
|
+
persisted.push(observation);
|
|
533
|
+
})
|
|
534
|
+
}).pipe(Effect.provide(transport.layer)));
|
|
535
|
+
assert.equal(transport.calls.length, 2);
|
|
536
|
+
assert.equal(persisted.length, 6);
|
|
537
|
+
assert.equal(report.counts.executionFailureCalls, 1);
|
|
538
|
+
assert.equal(report.counts.malformedCalls, 0);
|
|
539
|
+
assert.equal(report.counts.classifiedCalls, 1);
|
|
540
|
+
assert.equal(report.counts.notRunCalls, 4);
|
|
541
|
+
assert.equal(report.counts.unscoredControls, 15);
|
|
542
|
+
assert.ok(report.observations.slice(2).every((entry) => entry.outcome.kind === "not-run"));
|
|
543
|
+
assertRepositorySemanticCalibrationReportV1({ plan, report });
|
|
544
|
+
});
|
|
545
|
+
test("each finished observation is persisted before its sibling needs to finish", async () => {
|
|
546
|
+
const firstRecorded = Deferred.makeUnsafe();
|
|
547
|
+
const plan = compile();
|
|
548
|
+
const transport = transportFixture((request, ordinal) => Effect.gen(function* () {
|
|
549
|
+
if (request.foundryRole === "solution-critic-b" && request.operationId.includes(":repeat-1:"))
|
|
550
|
+
yield* Deferred.await(firstRecorded);
|
|
551
|
+
return { text: JSON.stringify(response(request)), callId: `hook-${String(ordinal)}` };
|
|
552
|
+
}));
|
|
553
|
+
const report = await Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
554
|
+
plan,
|
|
555
|
+
operationId: "prospective-observation",
|
|
556
|
+
recordObservation: (observation) => observation.role === "solution-critic-a" && observation.repetition === 1
|
|
557
|
+
? Deferred.succeed(firstRecorded, undefined).pipe(Effect.asVoid)
|
|
558
|
+
: Effect.void
|
|
559
|
+
}).pipe(Effect.provide(transport.layer), Effect.timeout("5 seconds")));
|
|
560
|
+
assert.equal(report.counts.classifiedCalls, 6);
|
|
561
|
+
});
|
|
562
|
+
test("required observation I/O failure propagates its original typed error, never a model outcome", async () => {
|
|
563
|
+
const requiredWriteFailure = new Error("required observation write failed");
|
|
564
|
+
const transport = transportFixture();
|
|
565
|
+
const result = await Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
566
|
+
plan: compile(),
|
|
567
|
+
operationId: "required-observation-io",
|
|
568
|
+
recordObservation: () => Effect.fail(requiredWriteFailure)
|
|
569
|
+
}).pipe(Effect.provide(transport.layer), Effect.match({ onFailure: (error) => error, onSuccess: () => undefined })));
|
|
570
|
+
assert.equal(result, requiredWriteFailure);
|
|
571
|
+
assert.ok(transport.calls.length <= 2);
|
|
572
|
+
});
|
|
573
|
+
for (const failedPhase of ["received", "validated"]) {
|
|
574
|
+
test(`required ${failedPhase} raw artifact persistence failure is fatal, not a counted model failure`, async () => {
|
|
575
|
+
const artifactWriteFailure = new RepositoryFoundryError({
|
|
576
|
+
operation: "execute-generation",
|
|
577
|
+
detail: "failed to persist private authoring evidence",
|
|
578
|
+
cause: new Error("synthetic required artifact write failure")
|
|
579
|
+
});
|
|
580
|
+
const transport = transportFixture();
|
|
581
|
+
const observations = [];
|
|
582
|
+
let reportReturned = false;
|
|
583
|
+
const result = await Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
584
|
+
plan: compile(),
|
|
585
|
+
operationId: `required-artifact-${failedPhase}`,
|
|
586
|
+
recordObservation: (observation) => Effect.sync(() => {
|
|
587
|
+
observations.push(observation);
|
|
588
|
+
})
|
|
589
|
+
}).pipe(Effect.provide(Layer.mergeAll(transport.layer, RepositoryFoundryProgressLive(undefined, (artifact) => artifact.validation === failedPhase ? Effect.fail(artifactWriteFailure) : Effect.void))), Effect.match({
|
|
590
|
+
onFailure: (error) => error,
|
|
591
|
+
onSuccess: () => {
|
|
592
|
+
reportReturned = true;
|
|
593
|
+
return undefined;
|
|
594
|
+
}
|
|
595
|
+
})));
|
|
596
|
+
assert.equal(result, artifactWriteFailure);
|
|
597
|
+
assert.equal(reportReturned, false);
|
|
598
|
+
assert.equal(observations.length, 0, "required I/O must not become execution-failure evidence");
|
|
599
|
+
assert.ok(transport.calls.length >= 1 && transport.calls.length <= 2);
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
test("interruption preserves returned observations without manufacturing a completed report", async () => {
|
|
603
|
+
const siblingStarted = Deferred.makeUnsafe();
|
|
604
|
+
const firstRecorded = Deferred.makeUnsafe();
|
|
605
|
+
let siblingInterrupted = false;
|
|
606
|
+
let reportReturned = false;
|
|
607
|
+
const persisted = [];
|
|
608
|
+
const transport = transportFixture((request, ordinal) => Effect.gen(function* () {
|
|
609
|
+
if (request.foundryRole === "solution-critic-a") {
|
|
610
|
+
yield* Deferred.await(siblingStarted);
|
|
611
|
+
return { text: JSON.stringify(response(request)), callId: `partial-${String(ordinal)}` };
|
|
612
|
+
}
|
|
613
|
+
yield* Deferred.succeed(siblingStarted, undefined);
|
|
614
|
+
return yield* Effect.never.pipe(Effect.onInterrupt(() => Effect.sync(() => {
|
|
615
|
+
siblingInterrupted = true;
|
|
616
|
+
})));
|
|
617
|
+
}));
|
|
618
|
+
const fiber = Effect.runFork(executeRepositorySemanticCalibrationPlanV1({
|
|
619
|
+
plan: compile(),
|
|
620
|
+
operationId: "interrupted-calibration",
|
|
621
|
+
recordObservation: (observation) => Effect.gen(function* () {
|
|
622
|
+
persisted.push(observation);
|
|
623
|
+
yield* Deferred.succeed(firstRecorded, undefined);
|
|
624
|
+
})
|
|
625
|
+
}).pipe(Effect.provide(transport.layer), Effect.tap(() => Effect.sync(() => {
|
|
626
|
+
reportReturned = true;
|
|
627
|
+
}))));
|
|
628
|
+
try {
|
|
629
|
+
await Effect.runPromise(Deferred.await(firstRecorded).pipe(Effect.timeout("5 seconds")));
|
|
630
|
+
}
|
|
631
|
+
finally {
|
|
632
|
+
await Effect.runPromise(Fiber.interrupt(fiber));
|
|
633
|
+
}
|
|
634
|
+
assert.equal(reportReturned, false);
|
|
635
|
+
assert.equal(siblingInterrupted, true);
|
|
636
|
+
assert.equal(persisted.length, 1);
|
|
637
|
+
assert.equal(persisted[0].outcome.kind, "classified");
|
|
638
|
+
});
|
|
639
|
+
test("report reconstruction rejects omitted, duplicate, relabeled, wrong-policy and altered-count evidence", async () => {
|
|
640
|
+
const plan = compile();
|
|
641
|
+
const transport = transportFixture();
|
|
642
|
+
const report = await Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
643
|
+
plan,
|
|
644
|
+
operationId: "report-integrity"
|
|
645
|
+
}).pipe(Effect.provide(transport.layer)));
|
|
646
|
+
for (const defect of [
|
|
647
|
+
"missing",
|
|
648
|
+
"duplicate",
|
|
649
|
+
"model",
|
|
650
|
+
"policy",
|
|
651
|
+
"counts",
|
|
652
|
+
"expected-label"
|
|
653
|
+
]) {
|
|
654
|
+
const altered = copy(report);
|
|
655
|
+
if (defect === "missing")
|
|
656
|
+
altered.observations.pop();
|
|
657
|
+
if (defect === "duplicate")
|
|
658
|
+
altered.observations[1] = altered.observations[0];
|
|
659
|
+
if (defect === "model")
|
|
660
|
+
altered.observations[0].model = "openai/other-model";
|
|
661
|
+
if (defect === "policy")
|
|
662
|
+
altered.observations[0].instructionsDigest = "f".repeat(64);
|
|
663
|
+
if (defect === "counts")
|
|
664
|
+
altered.counts.validAsWrong = 0;
|
|
665
|
+
if (defect === "counts")
|
|
666
|
+
altered.counts.validAsValid = 99;
|
|
667
|
+
if (defect === "expected-label")
|
|
668
|
+
altered.controls[0].expectedClass = "wrong";
|
|
669
|
+
assert.throws(() => assertRepositorySemanticCalibrationReportV1({ plan, report: altered }), defect);
|
|
670
|
+
}
|
|
671
|
+
const changedNotRun = copy(report.observations);
|
|
672
|
+
changedNotRun[0].outcome = { kind: "not-run", reason: "prior-execution-failure" };
|
|
673
|
+
assert.throws(() => compileRepositorySemanticCalibrationReportV1({
|
|
674
|
+
plan,
|
|
675
|
+
operationId: report.operationId,
|
|
676
|
+
observations: changedNotRun
|
|
677
|
+
}), /not-run/u);
|
|
678
|
+
});
|
|
679
|
+
test("a stale plan is rejected before touching the model transport", async () => {
|
|
680
|
+
const stale = copy(compile());
|
|
681
|
+
stale.repetitions += 1;
|
|
682
|
+
const transport = transportFixture();
|
|
683
|
+
await assert.rejects(Effect.runPromise(executeRepositorySemanticCalibrationPlanV1({
|
|
684
|
+
plan: stale,
|
|
685
|
+
operationId: "stale-calibration"
|
|
686
|
+
}).pipe(Effect.provide(transport.layer))), /plan failed validation/u);
|
|
687
|
+
assert.equal(transport.calls.length, 0);
|
|
688
|
+
});
|