@bjoernrochel/sevro 1.0.0 → 1.1.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/CONTRIBUTING.md +34 -4
- package/README.md +7 -6
- package/dist/examples/basic/graded.json +13 -0
- package/dist/examples/basic/host.js +9 -0
- package/dist/examples/basic/host.js.map +1 -0
- package/dist/examples/basic/prompt-only.json +7 -0
- package/dist/examples/recipes/candidate.js +23 -0
- package/dist/examples/recipes/candidate.js.map +1 -0
- package/dist/examples/recipes/cases/coding-change.json +21 -0
- package/dist/examples/recipes/cases/host-tools.json +21 -0
- package/dist/examples/recipes/cases/mise.json +21 -0
- package/dist/examples/recipes/cases/node.json +21 -0
- package/dist/examples/recipes/cases/python-uv.json +21 -0
- package/dist/examples/recipes/cases/semantic.json +17 -0
- package/dist/examples/recipes/coding-change/check.js +16 -0
- package/dist/examples/recipes/coding-change/check.js.map +1 -0
- package/dist/examples/recipes/executable.js +20 -0
- package/dist/examples/recipes/executable.js.map +1 -0
- package/dist/examples/recipes/extension-artifacts.js +56 -0
- package/dist/examples/recipes/extension-artifacts.js.map +1 -0
- package/dist/examples/recipes/extension-methods.js +167 -0
- package/dist/examples/recipes/extension-methods.js.map +1 -0
- package/dist/examples/recipes/extension.js +28 -0
- package/dist/examples/recipes/extension.js.map +1 -0
- package/dist/examples/recipes/modules.js +9 -0
- package/dist/examples/recipes/modules.js.map +1 -0
- package/dist/examples/recipes/repository-skill/.agents/skills/startup-guide/SKILL.md +7 -0
- package/dist/examples/recipes/repository-skill/.claude/skills/startup-guide/SKILL.md +7 -0
- package/dist/examples/recipes/repository-skill/README.md +3 -0
- package/dist/examples/recipes/run-inputs.js +144 -0
- package/dist/examples/recipes/run-inputs.js.map +1 -0
- package/dist/examples/recipes/run-options.js +103 -0
- package/dist/examples/recipes/run-options.js.map +1 -0
- package/dist/examples/recipes/run.js +62 -0
- package/dist/examples/recipes/run.js.map +1 -0
- package/dist/examples/recipes/runtime/empty.json +1 -0
- package/dist/examples/recipes/runtime/goals.json +1 -0
- package/dist/examples/recipes/runtime/mise.json +6 -0
- package/dist/examples/recipes/runtime/path.json +1 -0
- package/dist/examples/recipes/runtime/plugins.json +4 -0
- package/dist/examples/recipes/runtime/python-uv.json +10 -0
- package/dist/examples/recipes/semantic-judge.js +27 -0
- package/dist/examples/recipes/semantic-judge.js.map +1 -0
- package/dist/examples/templates/coding/adapter.js +14 -0
- package/dist/examples/templates/coding/adapter.js.map +1 -0
- package/dist/examples/templates/coding/case.json +15 -0
- package/dist/examples/templates/repository-skill/.agents/skills/startup-guide/SKILL.md +6 -0
- package/dist/examples/templates/repository-skill/extension-data.js +61 -0
- package/dist/examples/templates/repository-skill/extension-data.js.map +1 -0
- package/dist/examples/templates/repository-skill/extension.js +29 -0
- package/dist/examples/templates/repository-skill/extension.js.map +1 -0
- package/dist/examples/templates/response/adapter.js +13 -0
- package/dist/examples/templates/response/adapter.js.map +1 -0
- package/dist/examples/templates/response/case.json +13 -0
- package/dist/src/advisory.js +86 -0
- package/dist/src/advisory.js.map +1 -0
- package/dist/src/candidate-artifacts.js +139 -0
- package/dist/src/candidate-artifacts.js.map +1 -0
- package/dist/src/candidate-codex-state.js +110 -0
- package/dist/src/candidate-codex-state.js.map +1 -0
- package/dist/src/case-validation.js +92 -0
- package/dist/src/case-validation.js.map +1 -0
- package/dist/src/cli/cancellation.js +21 -0
- package/dist/src/cli/cancellation.js.map +1 -0
- package/dist/src/cli/command.js +60 -0
- package/dist/src/cli/command.js.map +1 -0
- package/dist/src/cli/completion.js +14 -0
- package/dist/src/cli/completion.js.map +1 -0
- package/dist/src/cli/demo.js +45 -0
- package/dist/src/cli/demo.js.map +1 -0
- package/dist/src/cli/evaluation.js +40 -0
- package/dist/src/cli/evaluation.js.map +1 -0
- package/dist/src/cli/extension.js +54 -0
- package/dist/src/cli/extension.js.map +1 -0
- package/dist/src/cli/help.js +190 -0
- package/dist/src/cli/help.js.map +1 -0
- package/dist/src/cli/hosts.js +33 -0
- package/dist/src/cli/hosts.js.map +1 -0
- package/dist/src/cli/init-settings.js +29 -0
- package/dist/src/cli/init-settings.js.map +1 -0
- package/dist/src/cli/init.js +82 -0
- package/dist/src/cli/init.js.map +1 -0
- package/dist/src/cli/invocation.js +431 -0
- package/dist/src/cli/invocation.js.map +1 -0
- package/dist/src/cli/loading.js +110 -0
- package/dist/src/cli/loading.js.map +1 -0
- package/dist/src/cli/preparation.js +88 -0
- package/dist/src/cli/preparation.js.map +1 -0
- package/dist/src/cli/presentation.js +61 -0
- package/dist/src/cli/presentation.js.map +1 -0
- package/dist/src/cli/progress.js +5 -0
- package/dist/src/cli/progress.js.map +1 -0
- package/dist/src/cli/run-manifest.js +108 -0
- package/dist/src/cli/run-manifest.js.map +1 -0
- package/dist/src/cli/run-options.js +367 -0
- package/dist/src/cli/run-options.js.map +1 -0
- package/dist/src/cli/run-overrides.js +51 -0
- package/dist/src/cli/run-overrides.js.map +1 -0
- package/dist/src/cli/settings.js +127 -0
- package/dist/src/cli/settings.js.map +1 -0
- package/dist/src/cli/summary.js +28 -0
- package/dist/src/cli/summary.js.map +1 -0
- package/dist/src/cli.js +20 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/contract-types.js +2 -0
- package/dist/src/contract-types.js.map +1 -0
- package/dist/src/engine.js +4 -0
- package/dist/src/engine.js.map +1 -0
- package/dist/src/evaluation/advisory.js +85 -0
- package/dist/src/evaluation/advisory.js.map +1 -0
- package/dist/src/evaluation/check-plan.js +292 -0
- package/dist/src/evaluation/check-plan.js.map +1 -0
- package/dist/src/evaluation/collection.js +61 -0
- package/dist/src/evaluation/collection.js.map +1 -0
- package/dist/src/evaluation/context.js +2 -0
- package/dist/src/evaluation/context.js.map +1 -0
- package/dist/src/evaluation/grading-host.js +28 -0
- package/dist/src/evaluation/grading-host.js.map +1 -0
- package/dist/src/evaluation/grading.js +154 -0
- package/dist/src/evaluation/grading.js.map +1 -0
- package/dist/src/evaluation/invocation-plan.js +312 -0
- package/dist/src/evaluation/invocation-plan.js.map +1 -0
- package/dist/src/evaluation/plan.js +376 -0
- package/dist/src/evaluation/plan.js.map +1 -0
- package/dist/src/evaluation/progress.js +14 -0
- package/dist/src/evaluation/progress.js.map +1 -0
- package/dist/src/evaluation/resources.js +159 -0
- package/dist/src/evaluation/resources.js.map +1 -0
- package/dist/src/evaluation/run.js +148 -0
- package/dist/src/evaluation/run.js.map +1 -0
- package/dist/src/evaluation/scheduler.js +27 -0
- package/dist/src/evaluation/scheduler.js.map +1 -0
- package/dist/src/evaluation/semantic.js +183 -0
- package/dist/src/evaluation/semantic.js.map +1 -0
- package/dist/src/evaluation/trial.js +593 -0
- package/dist/src/evaluation/trial.js.map +1 -0
- package/dist/src/evaluation/types.js +20 -0
- package/dist/src/evaluation/types.js.map +1 -0
- package/dist/src/evidence/host-results.js +67 -0
- package/dist/src/evidence/host-results.js.map +1 -0
- package/dist/src/evidence/retained-artifacts.js +17 -0
- package/dist/src/evidence/retained-artifacts.js.map +1 -0
- package/dist/src/evidence/trial-writer.js +131 -0
- package/dist/src/evidence/trial-writer.js.map +1 -0
- package/dist/src/evidence/usage.js +14 -0
- package/dist/src/evidence/usage.js.map +1 -0
- package/dist/src/executable.js +20 -0
- package/dist/src/executable.js.map +1 -0
- package/dist/src/extension-client.js +212 -0
- package/dist/src/extension-client.js.map +1 -0
- package/dist/src/extension-session.js +236 -0
- package/dist/src/extension-session.js.map +1 -0
- package/dist/src/fixtures/advisory.js +206 -0
- package/dist/src/fixtures/advisory.js.map +1 -0
- package/dist/src/fixtures/bin.js +41 -0
- package/dist/src/fixtures/bin.js.map +1 -0
- package/dist/src/fixtures/cleanup.js +43 -0
- package/dist/src/fixtures/cleanup.js.map +1 -0
- package/dist/src/fixtures/create.js +94 -0
- package/dist/src/fixtures/create.js.map +1 -0
- package/dist/src/fixtures/generated.js +181 -0
- package/dist/src/fixtures/generated.js.map +1 -0
- package/dist/src/fixtures/git-hooks.js +16 -0
- package/dist/src/fixtures/git-hooks.js.map +1 -0
- package/dist/src/fixtures/preparation.js +201 -0
- package/dist/src/fixtures/preparation.js.map +1 -0
- package/dist/src/fixtures/repository.js +255 -0
- package/dist/src/fixtures/repository.js.map +1 -0
- package/dist/src/fixtures/setup.js +175 -0
- package/dist/src/fixtures/setup.js.map +1 -0
- package/dist/src/fixtures/tools.js +57 -0
- package/dist/src/fixtures/tools.js.map +1 -0
- package/dist/src/fixtures/workspace-state.js +155 -0
- package/dist/src/fixtures/workspace-state.js.map +1 -0
- package/dist/src/generated/cli-result.cjs +2 -0
- package/dist/src/generated/extension.cjs +2 -0
- package/dist/src/generated/report.cjs +2 -0
- package/dist/src/generated/run-evidence.cjs +2 -0
- package/dist/src/generated/runtime.cjs +2 -0
- package/dist/src/git.js +72 -0
- package/dist/src/git.js.map +1 -0
- package/dist/src/graders/artifact.js +68 -0
- package/dist/src/graders/artifact.js.map +1 -0
- package/dist/src/graders/git-head.js +112 -0
- package/dist/src/graders/git-head.js.map +1 -0
- package/dist/src/graders/output.js +345 -0
- package/dist/src/graders/output.js.map +1 -0
- package/dist/src/graders/semantic.js +132 -0
- package/dist/src/graders/semantic.js.map +1 -0
- package/dist/src/graders/shell.js +321 -0
- package/dist/src/graders/shell.js.map +1 -0
- package/dist/src/host-diagnostic-redaction.js +52 -0
- package/dist/src/host-diagnostic-redaction.js.map +1 -0
- package/dist/src/host-diagnostics.js +248 -0
- package/dist/src/host-diagnostics.js.map +1 -0
- package/dist/src/hosts/claude-continuation.js +89 -0
- package/dist/src/hosts/claude-continuation.js.map +1 -0
- package/dist/src/hosts/claude-credential.js +121 -0
- package/dist/src/hosts/claude-credential.js.map +1 -0
- package/dist/src/hosts/claude-events.js +136 -0
- package/dist/src/hosts/claude-events.js.map +1 -0
- package/dist/src/hosts/claude-keychain.js +100 -0
- package/dist/src/hosts/claude-keychain.js.map +1 -0
- package/dist/src/hosts/claude-login-recovery.js +67 -0
- package/dist/src/hosts/claude-login-recovery.js.map +1 -0
- package/dist/src/hosts/claude-login-refresh.js +146 -0
- package/dist/src/hosts/claude-login-refresh.js.map +1 -0
- package/dist/src/hosts/claude-login-store.js +124 -0
- package/dist/src/hosts/claude-login-store.js.map +1 -0
- package/dist/src/hosts/claude-login.js +74 -0
- package/dist/src/hosts/claude-login.js.map +1 -0
- package/dist/src/hosts/claude-native-goal.js +138 -0
- package/dist/src/hosts/claude-native-goal.js.map +1 -0
- package/dist/src/hosts/claude-process.js +10 -0
- package/dist/src/hosts/claude-process.js.map +1 -0
- package/dist/src/hosts/claude-refresh-lock.js +76 -0
- package/dist/src/hosts/claude-refresh-lock.js.map +1 -0
- package/dist/src/hosts/claude-repository-invocation.js +229 -0
- package/dist/src/hosts/claude-repository-invocation.js.map +1 -0
- package/dist/src/hosts/claude-settings.js +156 -0
- package/dist/src/hosts/claude-settings.js.map +1 -0
- package/dist/src/hosts/claude-skill-activations.js +131 -0
- package/dist/src/hosts/claude-skill-activations.js.map +1 -0
- package/dist/src/hosts/claude-state.js +237 -0
- package/dist/src/hosts/claude-state.js.map +1 -0
- package/dist/src/hosts/claude-tool-calls.js +150 -0
- package/dist/src/hosts/claude-tool-calls.js.map +1 -0
- package/dist/src/hosts/claude.js +373 -0
- package/dist/src/hosts/claude.js.map +1 -0
- package/dist/src/hosts/codex-app-server.js +764 -0
- package/dist/src/hosts/codex-app-server.js.map +1 -0
- package/dist/src/hosts/codex-configuration.js +91 -0
- package/dist/src/hosts/codex-configuration.js.map +1 -0
- package/dist/src/hosts/codex-events.js +104 -0
- package/dist/src/hosts/codex-events.js.map +1 -0
- package/dist/src/hosts/codex-exec-controls.js +434 -0
- package/dist/src/hosts/codex-exec-controls.js.map +1 -0
- package/dist/src/hosts/codex-invocation.js +54 -0
- package/dist/src/hosts/codex-invocation.js.map +1 -0
- package/dist/src/hosts/codex-marketplace.js +185 -0
- package/dist/src/hosts/codex-marketplace.js.map +1 -0
- package/dist/src/hosts/codex-native-calls.js +516 -0
- package/dist/src/hosts/codex-native-calls.js.map +1 -0
- package/dist/src/hosts/codex-process.js +10 -0
- package/dist/src/hosts/codex-process.js.map +1 -0
- package/dist/src/hosts/codex-profile.js +206 -0
- package/dist/src/hosts/codex-profile.js.map +1 -0
- package/dist/src/hosts/codex-session-files.js +89 -0
- package/dist/src/hosts/codex-session-files.js.map +1 -0
- package/dist/src/hosts/codex-state.js +310 -0
- package/dist/src/hosts/codex-state.js.map +1 -0
- package/dist/src/hosts/codex.js +527 -0
- package/dist/src/hosts/codex.js.map +1 -0
- package/dist/src/hosts/isolation-common.js +43 -0
- package/dist/src/hosts/isolation-common.js.map +1 -0
- package/dist/src/hosts/isolation-roots.js +64 -0
- package/dist/src/hosts/isolation-roots.js.map +1 -0
- package/dist/src/hosts/isolation.js +12 -0
- package/dist/src/hosts/isolation.js.map +1 -0
- package/dist/src/hosts/linux-sandbox.js +127 -0
- package/dist/src/hosts/linux-sandbox.js.map +1 -0
- package/dist/src/hosts/mac-sandbox.js +137 -0
- package/dist/src/hosts/mac-sandbox.js.map +1 -0
- package/dist/src/hosts/native-controls.js +151 -0
- package/dist/src/hosts/native-controls.js.map +1 -0
- package/dist/src/hosts/native-request.js +33 -0
- package/dist/src/hosts/native-request.js.map +1 -0
- package/dist/src/hosts/process-lifecycle.js +167 -0
- package/dist/src/hosts/process-lifecycle.js.map +1 -0
- package/dist/src/hosts/protected-worktrees.js +81 -0
- package/dist/src/hosts/protected-worktrees.js.map +1 -0
- package/dist/src/hosts/skill-hook-catalog.js +100 -0
- package/dist/src/hosts/skill-hook-catalog.js.map +1 -0
- package/dist/src/hosts/skill-hook-handler.js +228 -0
- package/dist/src/hosts/skill-hook-handler.js.map +1 -0
- package/dist/src/hosts/skill-hooks.js +423 -0
- package/dist/src/hosts/skill-hooks.js.map +1 -0
- package/dist/src/hosts/workspace-fingerprint.js +72 -0
- package/dist/src/hosts/workspace-fingerprint.js.map +1 -0
- package/dist/src/identity.js +167 -0
- package/dist/src/identity.js.map +1 -0
- package/dist/src/instrumentation.js +83 -0
- package/dist/src/instrumentation.js.map +1 -0
- package/dist/src/native-transcript-state.js +85 -0
- package/dist/src/native-transcript-state.js.map +1 -0
- package/dist/src/native-transcript-view.js +65 -0
- package/dist/src/native-transcript-view.js.map +1 -0
- package/dist/src/native-transcripts.js +208 -0
- package/dist/src/native-transcripts.js.map +1 -0
- package/dist/src/paths.js +13 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/process-lifecycle.js +101 -0
- package/dist/src/process-lifecycle.js.map +1 -0
- package/dist/src/provenance.js +263 -0
- package/dist/src/provenance.js.map +1 -0
- package/dist/src/prune.js +228 -0
- package/dist/src/prune.js.map +1 -0
- package/dist/src/report.js +276 -0
- package/dist/src/report.js.map +1 -0
- package/dist/src/resolved-case.js +29 -0
- package/dist/src/resolved-case.js.map +1 -0
- package/dist/src/results-lock.js +40 -0
- package/dist/src/results-lock.js.map +1 -0
- package/dist/src/results.js +127 -0
- package/dist/src/results.js.map +1 -0
- package/dist/src/run-owner.js +283 -0
- package/dist/src/run-owner.js.map +1 -0
- package/dist/src/runner-paths.js +11 -0
- package/dist/src/runner-paths.js.map +1 -0
- package/dist/src/runtime/config.js +323 -0
- package/dist/src/runtime/config.js.map +1 -0
- package/dist/src/runtime/discovery-apple.js +65 -0
- package/dist/src/runtime/discovery-apple.js.map +1 -0
- package/dist/src/runtime/discovery-providers.js +37 -0
- package/dist/src/runtime/discovery-providers.js.map +1 -0
- package/dist/src/runtime/discovery.js +40 -0
- package/dist/src/runtime/discovery.js.map +1 -0
- package/dist/src/runtime/hook-processes.js +81 -0
- package/dist/src/runtime/hook-processes.js.map +1 -0
- package/dist/src/runtime/hooks.js +304 -0
- package/dist/src/runtime/hooks.js.map +1 -0
- package/dist/src/runtime/paths.js +244 -0
- package/dist/src/runtime/paths.js.map +1 -0
- package/dist/src/runtime/query.js +76 -0
- package/dist/src/runtime/query.js.map +1 -0
- package/dist/src/runtime/seeds.js +98 -0
- package/dist/src/runtime/seeds.js.map +1 -0
- package/dist/src/runtime/shared-cache.js +81 -0
- package/dist/src/runtime/shared-cache.js.map +1 -0
- package/dist/src/runtime/state.js +106 -0
- package/dist/src/runtime/state.js.map +1 -0
- package/dist/src/runtime-process.js +148 -0
- package/dist/src/runtime-process.js.map +1 -0
- package/dist/src/schema-types.js +2 -0
- package/dist/src/schema-types.js.map +1 -0
- package/dist/src/schema.js +16 -0
- package/dist/src/schema.js.map +1 -0
- package/dist/src/shell.js +5 -0
- package/dist/src/shell.js.map +1 -0
- package/dist/src/sqlite-lock.js +18 -0
- package/dist/src/sqlite-lock.js.map +1 -0
- package/dist/src/storage.js +21 -0
- package/dist/src/storage.js.map +1 -0
- package/dist/src/transcript-retention.js +109 -0
- package/dist/src/transcript-retention.js.map +1 -0
- package/dist/src/value-guards.js +26 -0
- package/dist/src/value-guards.js.map +1 -0
- package/docs/architecture.md +5 -2
- package/docs/creating-cases.md +2 -3
- package/docs/development-cli.md +12 -7
- package/docs/documentation-quality.md +4 -3
- package/docs/evaluation-workflow.md +8 -8
- package/docs/getting-started.md +7 -6
- package/docs/guide-evaluation.md +1 -1
- package/docs/identity-v1.md +4 -1
- package/docs/installing.md +31 -13
- package/docs/licensing.md +2 -2
- package/docs/native-hosts.md +1 -1
- package/docs/recipes.md +41 -40
- package/docs/releases.md +20 -4
- package/docs/run-settings-v1.md +3 -3
- package/docs/specs/repository-guide.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/typescript-quality.md +18 -1
- package/examples/recipes/executable.ts +19 -0
- package/examples/recipes/extension-artifacts.ts +1 -1
- package/examples/recipes/extension.ts +2 -1
- package/examples/recipes/modules.ts +9 -0
- package/examples/recipes/run-inputs.ts +14 -19
- package/examples/recipes/run-options.ts +9 -8
- package/examples/recipes/run.ts +21 -7
- package/examples/templates/repository-skill/extension-data.ts +1 -1
- package/examples/templates/repository-skill/extension.ts +2 -1
- package/package.json +14 -6
- package/src/cli/demo.ts +3 -2
- package/src/cli/help.ts +4 -3
- package/src/cli/init-settings.ts +5 -4
- package/src/cli/init.ts +9 -8
- package/src/cli/invocation.ts +2 -1
- package/src/cli/preparation.ts +2 -2
- package/src/cli.ts +1 -1
- package/src/executable.ts +19 -0
- package/src/extension-client.ts +6 -12
- package/src/fixtures/setup.ts +3 -2
- package/src/git.ts +2 -1
- package/src/graders/git-head.ts +3 -2
- package/src/graders/shell.ts +4 -3
- package/src/hosts/claude-keychain.ts +3 -2
- package/src/hosts/claude-login-refresh.ts +3 -2
- package/src/hosts/claude-refresh-lock.ts +2 -1
- package/src/hosts/isolation-roots.ts +3 -2
- package/src/hosts/process-lifecycle.ts +4 -6
- package/src/hosts/protected-worktrees.ts +2 -1
- package/src/hosts/skill-hook-handler.ts +1 -1
- package/src/hosts/skill-hooks.ts +10 -2
- package/src/provenance.ts +7 -6
- package/src/results-lock.ts +4 -4
- package/src/run-owner.ts +15 -9
- package/src/runner-paths.ts +21 -0
- package/src/runtime/hook-processes.ts +2 -1
- package/src/runtime/hooks.ts +9 -7
- package/src/runtime-process.ts +194 -0
- package/src/sqlite-lock.ts +25 -0
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
import { rm } from "node:fs/promises";
|
|
2
|
+
import { hashJson } from "../identity.js";
|
|
3
|
+
import { allocateCandidateRuntime, candidateArtifactRoots, releaseCandidateRuntime, } from "../candidate-artifacts.js";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { advisoryBaseRevision } from "../fixtures/advisory.js";
|
|
6
|
+
import { prepareTrialWorkspace } from "./resources.js";
|
|
7
|
+
import { hostArtifacts, hostObservations } from "../evidence/host-results.js";
|
|
8
|
+
import { TrialEvidenceWriter, } from "../evidence/trial-writer.js";
|
|
9
|
+
import { usage } from "../evidence/usage.js";
|
|
10
|
+
import { runAdvisoryReview } from "./advisory.js";
|
|
11
|
+
import { gradeCandidateOutput, gradeShellChecks, gradeGitHeadChecks, gradeExtensionChecks, } from "./grading.js";
|
|
12
|
+
import { gradeSemanticChecks } from "./semantic.js";
|
|
13
|
+
import { HostExecutionFailure, } from "./types.js";
|
|
14
|
+
import { clearFixtureContents, removeDisposableDirectory, } from "../fixtures/cleanup.js";
|
|
15
|
+
import { retainWorkspace } from "../fixtures/workspace-state.js";
|
|
16
|
+
import { gitHeadRevision } from "../graders/git-head.js";
|
|
17
|
+
import { InstrumentationEvidenceError, snapshotInstrumentation, verifyAppliedInstrumentation, } from "../instrumentation.js";
|
|
18
|
+
import { materializeNativeTranscriptView } from "../native-transcript-view.js";
|
|
19
|
+
import { applyTaskVerdictPolicy, assessTrial, } from "../results.js";
|
|
20
|
+
import { scheduleTrials } from "./scheduler.js";
|
|
21
|
+
import { rethrowDiagnosticPersistenceError } from "../host-diagnostics.js";
|
|
22
|
+
import { evaluationProgress } from "./progress.js";
|
|
23
|
+
const MAX_FINAL_MESSAGE_BYTES = 8 * 1024 * 1024;
|
|
24
|
+
function ensureNotCancelled(signal) {
|
|
25
|
+
if (signal?.aborted)
|
|
26
|
+
throw new Error("cancelled");
|
|
27
|
+
}
|
|
28
|
+
function hostFailureDiagnostic(execution, error) {
|
|
29
|
+
if (execution === "cancelled")
|
|
30
|
+
return { code: "sevro.run.cancelled", message: "run cancelled" };
|
|
31
|
+
if (error instanceof InstrumentationEvidenceError)
|
|
32
|
+
return { code: "sevro.instrumentation.mismatch", message: error.message };
|
|
33
|
+
if (error instanceof HostExecutionFailure)
|
|
34
|
+
return { code: "sevro.host.failed", message: error.message };
|
|
35
|
+
return {
|
|
36
|
+
code: "sevro.host.failed",
|
|
37
|
+
message: "host execution did not complete",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function extensionFinalMessageData(result) {
|
|
41
|
+
return result?.finalMessage == null ? {} : { text: result.finalMessage };
|
|
42
|
+
}
|
|
43
|
+
function compareDeclaredChecks(left, right, order) {
|
|
44
|
+
const leftIndex = order.get(left.id);
|
|
45
|
+
const rightIndex = order.get(right.id);
|
|
46
|
+
// Match the stable NaN comparator fallback; assessment reports undeclared IDs.
|
|
47
|
+
if (leftIndex === undefined || rightIndex === undefined)
|
|
48
|
+
return 0;
|
|
49
|
+
return leftIndex - rightIndex;
|
|
50
|
+
}
|
|
51
|
+
function selectedTrialTaskPolicy(options, recommendation) {
|
|
52
|
+
const id = options.extension?.session.identity.selectedTaskVerdictPolicy;
|
|
53
|
+
return id ? { id, recommendation } : null;
|
|
54
|
+
}
|
|
55
|
+
function initialTrialState(dry) {
|
|
56
|
+
return {
|
|
57
|
+
diagnostic: undefined,
|
|
58
|
+
persisted: false,
|
|
59
|
+
gitHeadBase: null,
|
|
60
|
+
advisoryRevision: null,
|
|
61
|
+
hostResult: null,
|
|
62
|
+
appliedInstrumentation: [],
|
|
63
|
+
additionalObservations: [],
|
|
64
|
+
producedArtifacts: [],
|
|
65
|
+
execution: dry ? "not_run" : "completed",
|
|
66
|
+
candidateDurationMs: null,
|
|
67
|
+
completeness: "unavailable",
|
|
68
|
+
observation: {
|
|
69
|
+
id: "sevro.observation.final-message",
|
|
70
|
+
source: "",
|
|
71
|
+
completeness: "unavailable",
|
|
72
|
+
data: {},
|
|
73
|
+
},
|
|
74
|
+
gradingObservations: [],
|
|
75
|
+
checks: [],
|
|
76
|
+
extensionMetrics: [],
|
|
77
|
+
domainOutcomes: [],
|
|
78
|
+
taskPolicyRecommendation: null,
|
|
79
|
+
graderError: false,
|
|
80
|
+
assessment: {
|
|
81
|
+
execution: { status: "not_run" },
|
|
82
|
+
grading: { status: "not_requested" },
|
|
83
|
+
task: { verdict: "not_assessed" },
|
|
84
|
+
},
|
|
85
|
+
advisoryReview: null,
|
|
86
|
+
retainedAuxiliaryWorkspaces: [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
class EvaluationTrial {
|
|
90
|
+
options;
|
|
91
|
+
context;
|
|
92
|
+
trial;
|
|
93
|
+
stopAdmission;
|
|
94
|
+
fixture;
|
|
95
|
+
state;
|
|
96
|
+
evidence;
|
|
97
|
+
constructor(options, context, trial, stopAdmission, fixture) {
|
|
98
|
+
this.options = options;
|
|
99
|
+
this.context = context;
|
|
100
|
+
this.trial = trial;
|
|
101
|
+
this.stopAdmission = stopAdmission;
|
|
102
|
+
this.fixture = fixture;
|
|
103
|
+
this.state = initialTrialState(options.dry);
|
|
104
|
+
this.state.candidateRuntimeRoot = fixture.candidateRuntimeRoot;
|
|
105
|
+
this.evidence = new TrialEvidenceWriter({
|
|
106
|
+
runDir: context.resources.runDir,
|
|
107
|
+
trial,
|
|
108
|
+
workspace: fixture.workspace,
|
|
109
|
+
preparationArtifacts: context.preparationArtifacts,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async run() {
|
|
113
|
+
try {
|
|
114
|
+
if (this.fixture.preparationCancelled)
|
|
115
|
+
return await this.cancelPreparation();
|
|
116
|
+
await this.initializeGradingBases();
|
|
117
|
+
await this.runCandidate();
|
|
118
|
+
await this.retainCandidateArtifacts();
|
|
119
|
+
this.observeCandidate();
|
|
120
|
+
await this.prepareCandidateArtifacts();
|
|
121
|
+
this.progress("grading", this.state.execution === "completed" ? "started" : "skipped");
|
|
122
|
+
this.gradeOutput();
|
|
123
|
+
await this.gradeShell();
|
|
124
|
+
await this.gradeGitHead();
|
|
125
|
+
await this.gradeSemantic();
|
|
126
|
+
await this.gradeExtension();
|
|
127
|
+
this.assess();
|
|
128
|
+
if (this.state.execution === "completed")
|
|
129
|
+
this.progress("grading", "completed");
|
|
130
|
+
await this.runAdvisory();
|
|
131
|
+
await this.retainRawCandidate();
|
|
132
|
+
return await this.persistTrial();
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
await this.cleanup();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async cancelPreparation() {
|
|
139
|
+
this.failCandidate(undefined);
|
|
140
|
+
await this.retainCandidateArtifacts();
|
|
141
|
+
this.observeCandidate();
|
|
142
|
+
this.assess();
|
|
143
|
+
return this.persistTrial();
|
|
144
|
+
}
|
|
145
|
+
async initializeGradingBases() {
|
|
146
|
+
this.state.gitHeadBase = this.context.prepared.checks.preparedGitHead.length
|
|
147
|
+
? await gitHeadRevision(this.fixture.workspace, this.options.signal)
|
|
148
|
+
: null;
|
|
149
|
+
this.state.advisoryRevision = this.options.advisoryHost
|
|
150
|
+
? await advisoryBaseRevision(this.fixture.workspace)
|
|
151
|
+
: null;
|
|
152
|
+
}
|
|
153
|
+
candidateRequest() {
|
|
154
|
+
return {
|
|
155
|
+
retainHostDiagnostics: (bytes) => this.evidence.retainArtifacts([{ id: "sevro.host.diagnostics", bytes: Buffer.from(bytes) }], "host-"),
|
|
156
|
+
candidateRuntimeRoot: this.state.candidateRuntimeRoot,
|
|
157
|
+
prompt: this.fixture.trialPrompt,
|
|
158
|
+
...(this.fixture.trialFollowUpPrompt !== undefined
|
|
159
|
+
? { followUpPrompt: this.fixture.trialFollowUpPrompt }
|
|
160
|
+
: {}),
|
|
161
|
+
workspace: this.fixture.workspace,
|
|
162
|
+
condition: this.options.condition,
|
|
163
|
+
fixtureBinDir: this.fixture.fixtureBinDir,
|
|
164
|
+
runtimePolicy: this.candidateRuntimePolicy(),
|
|
165
|
+
instrumentation: snapshotInstrumentation(this.context.prepared.requestedInstrumentation),
|
|
166
|
+
...structuredClone(this.context.prepared.invocation.hostRequest),
|
|
167
|
+
signal: this.options.signal,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
candidateRuntimePolicy() {
|
|
171
|
+
if (this.options.runtimePolicy)
|
|
172
|
+
return this.options.runtimePolicy;
|
|
173
|
+
if (!this.context.prepared.fixture.fixtureSetup)
|
|
174
|
+
return undefined;
|
|
175
|
+
return {
|
|
176
|
+
format: "sevro.runtime.v1",
|
|
177
|
+
environment: {},
|
|
178
|
+
readOnlyRoots: [],
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
candidateReservedIds() {
|
|
182
|
+
return new Set([
|
|
183
|
+
"sevro.observation.final-message",
|
|
184
|
+
"sevro.observation.workspaces",
|
|
185
|
+
...this.context.preparationArtifacts.map((item) => item.id),
|
|
186
|
+
...this.state.additionalObservations.map((item) => item.id),
|
|
187
|
+
...this.options.case.checks.map((item) => item.id),
|
|
188
|
+
...this.context.prepared.checks.preparedShell.map((item) => `sevro.observation.shell.${item.id}`),
|
|
189
|
+
...(this.context.prepared.checks.preparedGitHead.length
|
|
190
|
+
? ["sevro.observation.git-head"]
|
|
191
|
+
: []),
|
|
192
|
+
...(this.context.prepared.checks.preparedSemantic.length
|
|
193
|
+
? ["sevro.semantic.verdicts"]
|
|
194
|
+
: []),
|
|
195
|
+
]);
|
|
196
|
+
}
|
|
197
|
+
acceptCandidateResult(response) {
|
|
198
|
+
this.state.appliedInstrumentation = verifyAppliedInstrumentation(this.context.prepared.requestedInstrumentation, response.appliedInstrumentation, this.options.condition, response.actualCondition);
|
|
199
|
+
if (response.finalMessage !== null &&
|
|
200
|
+
Buffer.byteLength(response.finalMessage, "utf8") > MAX_FINAL_MESSAGE_BYTES)
|
|
201
|
+
throw new Error("oversized host result");
|
|
202
|
+
this.state.additionalObservations = hostObservations(response, this.options.host.id, new Set([
|
|
203
|
+
...this.context.preparationArtifacts.map((item) => item.id),
|
|
204
|
+
...this.options.case.checks.map((item) => item.id),
|
|
205
|
+
]));
|
|
206
|
+
this.state.producedArtifacts = hostArtifacts(response, this.candidateReservedIds());
|
|
207
|
+
if (response.executionFailed) {
|
|
208
|
+
this.state.execution = "failed";
|
|
209
|
+
this.stopAdmission();
|
|
210
|
+
this.state.diagnostic = {
|
|
211
|
+
code: "sevro.host.failed",
|
|
212
|
+
message: response.failureMessage ?? "host execution did not complete",
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
discardCandidateResult() {
|
|
217
|
+
this.state.hostResult = null;
|
|
218
|
+
this.state.appliedInstrumentation = [];
|
|
219
|
+
this.state.additionalObservations = [];
|
|
220
|
+
this.state.producedArtifacts = [];
|
|
221
|
+
}
|
|
222
|
+
failCandidate(error) {
|
|
223
|
+
this.stopAdmission();
|
|
224
|
+
this.discardCandidateResult();
|
|
225
|
+
try {
|
|
226
|
+
if (error instanceof HostExecutionFailure) {
|
|
227
|
+
this.acceptCandidateResult(error.result);
|
|
228
|
+
this.state.hostResult = error.result;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (validationError) {
|
|
232
|
+
this.discardCandidateResult();
|
|
233
|
+
error = validationError;
|
|
234
|
+
}
|
|
235
|
+
this.state.execution = this.options.signal?.aborted
|
|
236
|
+
? "cancelled"
|
|
237
|
+
: "failed";
|
|
238
|
+
this.state.diagnostic = hostFailureDiagnostic(this.state.execution, error);
|
|
239
|
+
}
|
|
240
|
+
async runCandidate() {
|
|
241
|
+
if (this.options.dry) {
|
|
242
|
+
this.progress("candidate", "skipped");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
this.progress("candidate", "started");
|
|
246
|
+
const started = performance.now();
|
|
247
|
+
try {
|
|
248
|
+
ensureNotCancelled(this.options.signal);
|
|
249
|
+
this.state.hostResult = await this.options.host.run(this.candidateRequest());
|
|
250
|
+
this.acceptCandidateResult(this.state.hostResult);
|
|
251
|
+
if (this.options.signal?.aborted) {
|
|
252
|
+
this.state.execution = "cancelled";
|
|
253
|
+
this.stopAdmission();
|
|
254
|
+
this.state.diagnostic = hostFailureDiagnostic("cancelled", undefined);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
rethrowDiagnosticPersistenceError(error);
|
|
259
|
+
this.failCandidate(error);
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
this.state.candidateDurationMs = Math.max(0, performance.now() - started);
|
|
263
|
+
this.progress("candidate", "completed");
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
async retainCandidateArtifacts() {
|
|
267
|
+
await this.evidence.retainArtifacts(this.state.producedArtifacts, "host-");
|
|
268
|
+
await this.evidence.verifyArtifacts();
|
|
269
|
+
const bundle = this.state.producedArtifacts.find((item) => item.id === "sevro.native-transcripts.bundle");
|
|
270
|
+
if (this.options.runtimePolicy?.nativeTranscripts && bundle)
|
|
271
|
+
this.state.candidateTranscriptRoot =
|
|
272
|
+
await materializeNativeTranscriptView(bundle.bytes);
|
|
273
|
+
}
|
|
274
|
+
observeCandidate() {
|
|
275
|
+
this.state.observation = this.evidence.observeCandidate(this.options.host.id, this.state.hostResult);
|
|
276
|
+
this.state.completeness = this.state.observation.completeness;
|
|
277
|
+
}
|
|
278
|
+
failGrading(message, cancelable = true) {
|
|
279
|
+
if (cancelable && this.options.signal?.aborted) {
|
|
280
|
+
this.state.execution = "cancelled";
|
|
281
|
+
this.state.diagnostic = {
|
|
282
|
+
code: "sevro.run.cancelled",
|
|
283
|
+
message: "run cancelled",
|
|
284
|
+
};
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
this.state.graderError = true;
|
|
288
|
+
this.state.diagnostic = { code: "sevro.grader.error", message };
|
|
289
|
+
this.stopAdmission();
|
|
290
|
+
}
|
|
291
|
+
canGrade() {
|
|
292
|
+
return this.state.execution === "completed" && !this.state.graderError;
|
|
293
|
+
}
|
|
294
|
+
async prepareCandidateArtifacts() {
|
|
295
|
+
if (this.state.execution !== "completed")
|
|
296
|
+
return;
|
|
297
|
+
try {
|
|
298
|
+
this.state.candidateArtifacts = await candidateArtifactRoots(this.state.candidateRuntimeRoot);
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
this.failGrading("candidate artifact directories are missing or unsafe");
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
acceptGradingFailure(failure) {
|
|
305
|
+
if (failure)
|
|
306
|
+
this.failGrading(failure.message, failure.cancelable);
|
|
307
|
+
}
|
|
308
|
+
gradeOutput() {
|
|
309
|
+
if (this.state.execution !== "completed")
|
|
310
|
+
return;
|
|
311
|
+
const graded = gradeCandidateOutput({
|
|
312
|
+
result: this.state.hostResult,
|
|
313
|
+
checks: this.context.prepared.checks.prepared,
|
|
314
|
+
evidenceRefs: this.evidence.hasCandidateMessage
|
|
315
|
+
? [this.state.observation.id]
|
|
316
|
+
: [],
|
|
317
|
+
});
|
|
318
|
+
this.state.checks = graded.checks;
|
|
319
|
+
this.acceptGradingFailure(graded.failure);
|
|
320
|
+
}
|
|
321
|
+
shellRootRequest() {
|
|
322
|
+
const isolation = this.options.shellIsolation;
|
|
323
|
+
if (!isolation)
|
|
324
|
+
return null;
|
|
325
|
+
return {
|
|
326
|
+
workspace: this.fixture.workspace,
|
|
327
|
+
projectRoot: this.context.prepared.fixture.projectRoot,
|
|
328
|
+
resultsRoot: this.options.resultsRoot,
|
|
329
|
+
additionalRoots: [
|
|
330
|
+
...isolation.protectedRoots,
|
|
331
|
+
...(this.options.preparationSources
|
|
332
|
+
? [this.options.preparationSources.root]
|
|
333
|
+
: []),
|
|
334
|
+
...(this.context.prepared.fixture.source.kind === "repository"
|
|
335
|
+
? [this.context.prepared.fixture.source.repository.path]
|
|
336
|
+
: []),
|
|
337
|
+
this.context.resources.runStateRoot,
|
|
338
|
+
],
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
async gradeShell() {
|
|
342
|
+
if (!this.canGrade() ||
|
|
343
|
+
this.context.prepared.checks.preparedShell.length === 0)
|
|
344
|
+
return;
|
|
345
|
+
const graded = await gradeShellChecks({
|
|
346
|
+
checks: this.context.prepared.checks.preparedShell,
|
|
347
|
+
protectedRoots: this.shellRootRequest(),
|
|
348
|
+
execution: {
|
|
349
|
+
candidateTranscriptRoot: this.state.candidateTranscriptRoot,
|
|
350
|
+
candidateArtifactRoots: this.state.candidateArtifacts,
|
|
351
|
+
workspace: this.fixture.workspace,
|
|
352
|
+
fixtureBinDir: this.fixture.fixtureBinDir,
|
|
353
|
+
toolchainBinDir: this.options.shellIsolation?.toolchainBinDir,
|
|
354
|
+
runtimePolicy: this.options.runtimePolicy,
|
|
355
|
+
uvRuntimeCache: this.options.shellIsolation?.uvRuntimeCache,
|
|
356
|
+
privateStateRoot: join(this.context.resources.stateDir, "shell-sandbox"),
|
|
357
|
+
signal: this.options.signal,
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
this.acceptGradingFailure(graded.failure);
|
|
361
|
+
this.state.gradingObservations.push(...graded.observations);
|
|
362
|
+
this.state.checks.push(...graded.checks);
|
|
363
|
+
}
|
|
364
|
+
async gradeGitHead() {
|
|
365
|
+
if (!this.canGrade() ||
|
|
366
|
+
this.context.prepared.checks.preparedGitHead.length === 0)
|
|
367
|
+
return;
|
|
368
|
+
const graded = await gradeGitHeadChecks({
|
|
369
|
+
checks: this.context.prepared.checks.preparedGitHead,
|
|
370
|
+
base: this.state.gitHeadBase,
|
|
371
|
+
workspace: this.fixture.workspace,
|
|
372
|
+
signal: this.options.signal,
|
|
373
|
+
});
|
|
374
|
+
this.acceptGradingFailure(graded.failure);
|
|
375
|
+
this.state.gradingObservations.push(...graded.observations);
|
|
376
|
+
this.state.checks.push(...graded.checks);
|
|
377
|
+
}
|
|
378
|
+
completeCandidateMessage() {
|
|
379
|
+
const result = this.state.hostResult;
|
|
380
|
+
if (result?.finalMessage == null || !result.complete)
|
|
381
|
+
return null;
|
|
382
|
+
return result.finalMessage;
|
|
383
|
+
}
|
|
384
|
+
async gradeSemantic() {
|
|
385
|
+
if (!this.canGrade())
|
|
386
|
+
return;
|
|
387
|
+
const graded = await gradeSemanticChecks({
|
|
388
|
+
checks: this.context.prepared.checks.preparedSemantic,
|
|
389
|
+
declaredChecks: this.options.case.checks,
|
|
390
|
+
host: this.options.semanticHost,
|
|
391
|
+
message: this.completeCandidateMessage(),
|
|
392
|
+
candidateWorkspace: this.fixture.workspace,
|
|
393
|
+
candidateTranscriptRoot: this.state.candidateTranscriptRoot,
|
|
394
|
+
candidateArtifactRoots: this.state.candidateArtifacts,
|
|
395
|
+
projectRoot: this.context.prepared.fixture.projectRoot,
|
|
396
|
+
reservedWorkspace: this.context.resources.workspaces.semantic(this.trial),
|
|
397
|
+
runtimePolicy: this.options.runtimePolicy,
|
|
398
|
+
signal: this.options.signal,
|
|
399
|
+
}, {
|
|
400
|
+
evidence: this.evidence,
|
|
401
|
+
onFailure: (failure) => {
|
|
402
|
+
this.acceptGradingFailure(failure);
|
|
403
|
+
},
|
|
404
|
+
retainWorkspace: (workspace) => this.retainAuxiliaryWorkspace(workspace),
|
|
405
|
+
});
|
|
406
|
+
this.state.gradingObservations.push(...graded.observations);
|
|
407
|
+
this.state.checks.push(...graded.checks);
|
|
408
|
+
}
|
|
409
|
+
trialObservations() {
|
|
410
|
+
return [
|
|
411
|
+
this.state.observation,
|
|
412
|
+
...this.state.gradingObservations,
|
|
413
|
+
...this.state.additionalObservations,
|
|
414
|
+
{
|
|
415
|
+
id: "sevro.observation.workspaces",
|
|
416
|
+
source: "sevro.runner",
|
|
417
|
+
completeness: "complete",
|
|
418
|
+
data: {
|
|
419
|
+
candidate: this.fixture.workspace,
|
|
420
|
+
retainedAuxiliary: this.state.retainedAuxiliaryWorkspaces,
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
];
|
|
424
|
+
}
|
|
425
|
+
extensionEvaluationRequest() {
|
|
426
|
+
return {
|
|
427
|
+
caseId: this.options.case.id,
|
|
428
|
+
execution: { status: this.state.execution },
|
|
429
|
+
observations: this.trialObservations().map((observation) => observation === this.state.observation
|
|
430
|
+
? {
|
|
431
|
+
...observation,
|
|
432
|
+
completeness: this.state.completeness,
|
|
433
|
+
data: {
|
|
434
|
+
...observation.data,
|
|
435
|
+
...extensionFinalMessageData(this.state.hostResult),
|
|
436
|
+
},
|
|
437
|
+
}
|
|
438
|
+
: observation),
|
|
439
|
+
builtinChecks: this.state.checks.map((check) => ({
|
|
440
|
+
id: check.id,
|
|
441
|
+
status: check.status,
|
|
442
|
+
...(check.detail ? { detail: check.detail } : {}),
|
|
443
|
+
evidenceRefs: check.evidenceRefs ?? [],
|
|
444
|
+
})),
|
|
445
|
+
artifacts: this.evidence.artifactRefs,
|
|
446
|
+
extensionData: this.context.prepared.extensionData,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
async gradeExtension() {
|
|
450
|
+
const extension = this.options.extension;
|
|
451
|
+
if (!extension || !this.canGrade())
|
|
452
|
+
return;
|
|
453
|
+
const graded = await gradeExtensionChecks({
|
|
454
|
+
evaluate: (request) => extension.session.evaluate(request),
|
|
455
|
+
request: this.extensionEvaluationRequest(),
|
|
456
|
+
declarations: this.context.prepared.checks.extensionDeclarations,
|
|
457
|
+
});
|
|
458
|
+
this.acceptGradingFailure(graded.failure);
|
|
459
|
+
this.state.checks.push(...graded.checks);
|
|
460
|
+
this.state.extensionMetrics = graded.metrics;
|
|
461
|
+
this.state.domainOutcomes = graded.domainOutcomes;
|
|
462
|
+
this.state.taskPolicyRecommendation = graded.recommendation;
|
|
463
|
+
}
|
|
464
|
+
assess() {
|
|
465
|
+
const declaredOrder = new Map(this.options.case.checks.map((check, index) => [check.id, index]));
|
|
466
|
+
this.state.checks.sort((left, right) => compareDeclaredChecks(left, right, declaredOrder));
|
|
467
|
+
const defaultAssessment = assessTrial({
|
|
468
|
+
execution: this.state.execution,
|
|
469
|
+
declaredChecks: this.options.case.checks
|
|
470
|
+
.filter((check) => !this.context.prepared.checks.replaced.has(check.grader))
|
|
471
|
+
.map((check) => check.id),
|
|
472
|
+
checks: this.state.checks,
|
|
473
|
+
graderError: this.state.graderError,
|
|
474
|
+
requiredEvidenceUnavailable: this.options.case.requiredEvidence.some((id) => !this.state.producedArtifacts.some((item) => item.id === id) &&
|
|
475
|
+
!this.trialObservations().some((item) => item.id === id && item.completeness === "complete")),
|
|
476
|
+
});
|
|
477
|
+
this.state.assessment = applyTaskVerdictPolicy(defaultAssessment, this.state.taskPolicyRecommendation, Boolean(this.options.extension?.session.identity.selectedTaskVerdictPolicy));
|
|
478
|
+
}
|
|
479
|
+
retainAuxiliaryWorkspace(workspace) {
|
|
480
|
+
this.state.retainedAuxiliaryWorkspaces.push(workspace);
|
|
481
|
+
this.context.resources.workspaces.retain(workspace);
|
|
482
|
+
return retainWorkspace(workspace);
|
|
483
|
+
}
|
|
484
|
+
async runAdvisory() {
|
|
485
|
+
const host = this.options.advisoryHost;
|
|
486
|
+
if (!host)
|
|
487
|
+
return;
|
|
488
|
+
this.state.advisoryReview = await runAdvisoryReview({
|
|
489
|
+
host,
|
|
490
|
+
candidateCompleted: this.state.execution === "completed",
|
|
491
|
+
candidateWorkspace: this.fixture.workspace,
|
|
492
|
+
candidateTranscriptRoot: this.state.candidateTranscriptRoot,
|
|
493
|
+
candidateArtifactRoots: this.state.candidateArtifacts,
|
|
494
|
+
baseRevision: this.state.advisoryRevision,
|
|
495
|
+
excludedPaths: this.options.advisoryExcludedPaths,
|
|
496
|
+
task: this.fixture.trialPrompt,
|
|
497
|
+
checks: this.state.checks,
|
|
498
|
+
declaredChecks: this.options.case.checks,
|
|
499
|
+
runtimePolicy: this.options.runtimePolicy,
|
|
500
|
+
signal: this.options.signal,
|
|
501
|
+
}, {
|
|
502
|
+
evidence: this.evidence,
|
|
503
|
+
retainWorkspace: (workspace) => this.retainAuxiliaryWorkspace(workspace),
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
retainRawCandidate() {
|
|
507
|
+
return this.evidence.retainRawCandidate(this.state.hostResult?.finalMessage);
|
|
508
|
+
}
|
|
509
|
+
trialEvidenceRecord() {
|
|
510
|
+
return {
|
|
511
|
+
caseId: this.options.case.id,
|
|
512
|
+
trial: this.trial,
|
|
513
|
+
executionMode: this.options.dry ? "dry" : "executed",
|
|
514
|
+
candidateDurationMs: this.state.candidateDurationMs,
|
|
515
|
+
condition: {
|
|
516
|
+
requested: this.options.condition,
|
|
517
|
+
actual: this.state.hostResult?.actualCondition ?? "unknown",
|
|
518
|
+
appliedInstrumentation: this.state.appliedInstrumentation,
|
|
519
|
+
},
|
|
520
|
+
observationCompleteness: this.state.completeness,
|
|
521
|
+
observations: this.trialObservations(),
|
|
522
|
+
metrics: this.state.extensionMetrics,
|
|
523
|
+
domainOutcomes: this.state.domainOutcomes,
|
|
524
|
+
taskVerdictPolicy: selectedTrialTaskPolicy(this.options, this.state.taskPolicyRecommendation),
|
|
525
|
+
advisoryReview: this.state.advisoryReview,
|
|
526
|
+
routes: this.context.prepared.routes,
|
|
527
|
+
usage: usage(this.state.hostResult),
|
|
528
|
+
rawResult: this.evidence.candidateRawResult(this.options.host.id),
|
|
529
|
+
artifactRefs: this.evidence.artifactRefs,
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
async persistTrial() {
|
|
533
|
+
const evidence = this.trialEvidenceRecord();
|
|
534
|
+
this.progress("evidence", "started");
|
|
535
|
+
const trialSummary = await this.evidence.persistTrial(this.options.case.id, this.state.assessment, this.state.checks, this.state.domainOutcomes, evidence);
|
|
536
|
+
this.state.persisted = true;
|
|
537
|
+
this.state.diagnostic = this.evidence.diagnosticLocation(this.state.diagnostic);
|
|
538
|
+
this.context.results.complete({
|
|
539
|
+
summary: trialSummary,
|
|
540
|
+
evidence,
|
|
541
|
+
diagnostic: this.state.diagnostic,
|
|
542
|
+
});
|
|
543
|
+
this.progress("evidence", "completed");
|
|
544
|
+
return !((this.state.execution !== "completed" &&
|
|
545
|
+
this.state.execution !== "not_run") ||
|
|
546
|
+
this.state.graderError);
|
|
547
|
+
}
|
|
548
|
+
progress(stage, status) {
|
|
549
|
+
evaluationProgress(this.options, stage, status, this.trial);
|
|
550
|
+
}
|
|
551
|
+
async cleanup() {
|
|
552
|
+
await removeDisposableDirectory(join(this.context.resources.stateDir, "shell-sandbox/runtime", hashJson(this.fixture.workspace)));
|
|
553
|
+
if (this.state.candidateTranscriptRoot)
|
|
554
|
+
await rm(this.state.candidateTranscriptRoot, {
|
|
555
|
+
recursive: true,
|
|
556
|
+
force: true,
|
|
557
|
+
});
|
|
558
|
+
if (this.state.persisted && !this.retainFailedWorkspace()) {
|
|
559
|
+
try {
|
|
560
|
+
await clearFixtureContents(this.fixture.workspace);
|
|
561
|
+
this.context.resources.workspaces.completed(this.fixture.reservation);
|
|
562
|
+
}
|
|
563
|
+
catch {
|
|
564
|
+
console.warn(`fixture cleanup failed; retained at ${this.fixture.workspace}`);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
retainFailedWorkspace() {
|
|
569
|
+
return (this.state.execution === "failed" ||
|
|
570
|
+
this.state.execution === "cancelled" ||
|
|
571
|
+
this.state.graderError ||
|
|
572
|
+
this.state.assessment.grading.status === "unavailable" ||
|
|
573
|
+
this.state.assessment.task.verdict === "failed");
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
export async function executeEvaluationTrials(options, context) {
|
|
577
|
+
await scheduleTrials({
|
|
578
|
+
count: options.trialCount,
|
|
579
|
+
jobs: context.prepared.jobs,
|
|
580
|
+
signal: options.signal,
|
|
581
|
+
}, async (trial, stopAdmission) => {
|
|
582
|
+
const candidateRuntimeRoot = await allocateCandidateRuntime(options.runtimePolicy, Boolean(context.prepared.fixture.fixtureSetup));
|
|
583
|
+
try {
|
|
584
|
+
const fixture = await prepareTrialWorkspace(options, context.prepared.fixture, context.prepared.invocation, context.resources.workspaces, trial, candidateRuntimeRoot);
|
|
585
|
+
evaluationProgress(options, "preparation", "completed", trial);
|
|
586
|
+
return await new EvaluationTrial(options, context, trial, stopAdmission, fixture).run();
|
|
587
|
+
}
|
|
588
|
+
finally {
|
|
589
|
+
await releaseCandidateRuntime(candidateRuntimeRoot);
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
//# sourceMappingURL=trial.js.map
|