@orion-agents/orion-code 0.3.65 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +128 -2
- package/README.md +78 -361
- package/README.zh-CN.md +71 -263
- package/bin/orion +4 -1
- package/dist/acp/session-updates.d.ts +34 -0
- package/dist/acp/session-updates.js +162 -0
- package/dist/acp/sessions.d.ts +32 -0
- package/dist/acp/sessions.js +315 -0
- package/dist/acp/stdio.d.ts +3 -0
- package/dist/acp/stdio.js +59 -0
- package/dist/cli.js +136 -185
- package/dist/commands/context-tool-command-handlers.d.ts +1 -1
- package/dist/commands/context-tool-command-handlers.js +24 -3
- package/dist/commands/core-command-handlers.js +5 -1
- package/dist/commands/diagnostic-command-handlers.js +20 -6
- package/dist/commands/diagnostic-commands.js +0 -12
- package/dist/commands/init-command.d.ts +3 -0
- package/dist/commands/init-command.js +131 -0
- package/dist/commands/model-command-handlers.d.ts +1 -2
- package/dist/commands/model-command-handlers.js +15 -100
- package/dist/commands/model-commands.js +0 -11
- package/dist/commands/registry.js +0 -18
- package/dist/commands/rsi-command.d.ts +2 -0
- package/dist/commands/rsi-command.js +180 -0
- package/dist/commands/session-command-handlers.js +28 -19
- package/dist/commands/system-commands.js +0 -1
- package/dist/commands/tool-commands.js +1 -1
- package/dist/commands/types.d.ts +4 -10
- package/dist/commands/types.js +1 -21
- package/dist/commands/workflow-command-handlers.js +13 -4
- package/dist/framework/loop-budget-contract.d.ts +7 -2
- package/dist/framework/loop-budget-contract.js +4 -1
- package/dist/framework/loop-progress.d.ts +22 -0
- package/dist/framework/loop-progress.js +79 -0
- package/dist/framework/prompt.d.ts +0 -2
- package/dist/framework/prompt.js +9 -27
- package/dist/framework/query.d.ts +27 -20
- package/dist/framework/query.js +453 -153
- package/dist/framework/store.d.ts +6 -10
- package/dist/framework/store.js +2 -21
- package/dist/framework/tool-call-orchestrator.d.ts +7 -0
- package/dist/framework/tool-call-orchestrator.js +8 -3
- package/dist/framework/tool-state.d.ts +2 -0
- package/dist/framework/tool.d.ts +0 -23
- package/dist/framework/verification-command.d.ts +15 -0
- package/dist/framework/verification-command.js +32 -0
- package/dist/harness/assembler.d.ts +1 -0
- package/dist/harness/assembler.js +24 -0
- package/dist/harness/capsule.d.ts +1 -1
- package/dist/harness/capsule.js +33 -14
- package/dist/harness/context-harness.d.ts +31 -12
- package/dist/harness/context-harness.js +491 -35
- package/dist/harness/contract.js +1 -1
- package/dist/harness/drift-guard.d.ts +4 -0
- package/dist/harness/drift-guard.js +68 -16
- package/dist/harness/intent.js +21 -0
- package/dist/harness/ledger.d.ts +6 -11
- package/dist/harness/ledger.js +39 -9
- package/dist/harness/progress-controller.d.ts +12 -7
- package/dist/harness/progress-controller.js +66 -21
- package/dist/harness/state.js +9 -1
- package/dist/harness/task-checklist.d.ts +16 -0
- package/dist/harness/task-checklist.js +95 -0
- package/dist/harness/types.d.ts +73 -1
- package/dist/harness/verification.d.ts +19 -1
- package/dist/harness/verification.js +116 -29
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/print-ui/event-stream.d.ts +38 -0
- package/dist/print-ui/event-stream.js +187 -0
- package/dist/print-ui/launch.d.ts +12 -1
- package/dist/print-ui/launch.js +173 -11
- package/dist/product/environment.d.ts +1 -1
- package/dist/product/environment.js +1 -1
- package/dist/product/identity.d.ts +1 -1
- package/dist/product/identity.js +1 -1
- package/dist/product/paths.d.ts +3 -2
- package/dist/product/paths.js +6 -2
- package/dist/runtime/agent-loop.d.ts +11 -2
- package/dist/runtime/agent-loop.js +165 -25
- package/dist/runtime/agent-runtime-controller.d.ts +13 -3
- package/dist/runtime/agent-runtime-controller.js +347 -183
- package/dist/runtime/agent-runtime-protocol.d.ts +10 -18
- package/dist/runtime/agent-runtime-runner.d.ts +10 -0
- package/dist/runtime/builtin-tool-provider.js +5 -1
- package/dist/runtime/capability-receipt-journal.js +1 -0
- package/dist/runtime/durable-tool-receipt-reader.js +2 -1
- package/dist/runtime/first-party-tool-services.d.ts +1 -0
- package/dist/runtime/first-party-tool-services.js +2 -12
- package/dist/runtime/first-party-tool-universe.d.ts +1 -0
- package/dist/runtime/first-party-tool-universe.js +1 -1
- package/dist/runtime/followup-queue-store.d.ts +16 -0
- package/dist/runtime/followup-queue-store.js +75 -0
- package/dist/runtime/goal-lifecycle-v2.d.ts +11 -1
- package/dist/runtime/goal-lifecycle-v2.js +85 -15
- package/dist/runtime/goal-runtime-coordinator.d.ts +10 -1
- package/dist/runtime/goal-runtime-coordinator.js +81 -24
- package/dist/runtime/loop-budget.js +7 -5
- package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +2 -0
- package/dist/runtime/mcp/first-party-mcp-adapter.js +23 -19
- package/dist/runtime/model-coordinator.js +2 -5
- package/dist/runtime/orion-runtime-v1.d.ts +18 -2
- package/dist/runtime/orion-runtime-v1.js +135 -39
- package/dist/runtime/orion-session-runner.d.ts +7 -0
- package/dist/runtime/orion-session-runner.js +82 -0
- package/dist/runtime/plan-review.d.ts +1 -0
- package/dist/runtime/plan-review.js +8 -4
- package/dist/runtime/product-bootstrap.d.ts +6 -0
- package/dist/runtime/product-bootstrap.js +41 -51
- package/dist/runtime/product-orion-runtime.js +128 -52
- package/dist/runtime/release-receipts.d.ts +24 -124
- package/dist/runtime/release-receipts.js +129 -683
- package/dist/runtime/rich-text/layout.js +108 -65
- package/dist/runtime/rsi/contracts.d.ts +50 -0
- package/dist/runtime/rsi/contracts.js +17 -0
- package/dist/runtime/rsi/diagnosis.d.ts +46 -0
- package/dist/runtime/rsi/diagnosis.js +98 -0
- package/dist/runtime/rsi/evaluation-suite.d.ts +25 -0
- package/dist/runtime/rsi/evaluation-suite.js +141 -0
- package/dist/runtime/rsi/evaluation-worker.d.ts +19 -0
- package/dist/runtime/rsi/evaluation-worker.js +64 -0
- package/dist/runtime/rsi/evaluation.d.ts +49 -0
- package/dist/runtime/rsi/evaluation.js +351 -0
- package/dist/runtime/rsi/lifecycle.d.ts +54 -0
- package/dist/runtime/rsi/lifecycle.js +279 -0
- package/dist/runtime/rsi/proposal.d.ts +39 -0
- package/dist/runtime/rsi/proposal.js +312 -0
- package/dist/runtime/rsi/receipt.d.ts +28 -0
- package/dist/runtime/rsi/receipt.js +138 -0
- package/dist/runtime/rsi/skill-state.d.ts +7 -0
- package/dist/runtime/rsi/skill-state.js +50 -0
- package/dist/runtime/rsi/trajectory.d.ts +19 -0
- package/dist/runtime/rsi/trajectory.js +314 -0
- package/dist/runtime/rsi/triage.d.ts +274 -0
- package/dist/runtime/rsi/triage.js +58 -0
- package/dist/runtime/session-composer-control.d.ts +5 -24
- package/dist/runtime/session-composer-control.js +27 -189
- package/dist/runtime/step-snapshot.d.ts +1 -0
- package/dist/runtime/subagents/policy.js +0 -1
- package/dist/runtime/subagents/production.js +1 -1
- package/dist/runtime/subagents/runtime-integration.js +2 -4
- package/dist/runtime/subagents/types.d.ts +0 -5
- package/dist/runtime/subagents/types.js +0 -2
- package/dist/runtime/task-context-recovery.d.ts +55 -0
- package/dist/runtime/task-context-recovery.js +342 -0
- package/dist/runtime/task-context-service.d.ts +16 -10
- package/dist/runtime/task-context-service.js +35 -4
- package/dist/runtime/thread-admission.d.ts +1 -1
- package/dist/runtime/thread-admission.js +12 -6
- package/dist/runtime/thread-event-store.d.ts +2 -2
- package/dist/runtime/thread-event-store.js +7 -2
- package/dist/runtime/thread-projection.js +4 -2
- package/dist/runtime/thread-runtime.d.ts +7 -0
- package/dist/runtime/thread-runtime.js +43 -0
- package/dist/runtime/thread-session-index.d.ts +8 -0
- package/dist/runtime/thread-session-index.js +50 -1
- package/dist/runtime/thread-session-view.d.ts +2 -1
- package/dist/runtime/thread-session-view.js +4 -0
- package/dist/runtime/thread-tool-journal.d.ts +1 -0
- package/dist/runtime/thread-tool-journal.js +6 -2
- package/dist/runtime/thread-ui-adapter.d.ts +1 -0
- package/dist/runtime/thread-ui-adapter.js +88 -11
- package/dist/runtime/tool-gateway.d.ts +7 -0
- package/dist/runtime/tool-gateway.js +20 -0
- package/dist/runtime/tool-transcript-entry.d.ts +16 -0
- package/dist/runtime/tool-transcript-entry.js +73 -0
- package/dist/runtime/turn-commit.d.ts +4 -1
- package/dist/runtime/turn-commit.js +19 -15
- package/dist/runtime/ui-events.d.ts +12 -0
- package/dist/runtime/ui-view-model.d.ts +6 -5
- package/dist/runtime/ui-view-model.js +33 -19
- package/dist/runtime/workspace-runtime-kernel.js +0 -1
- package/dist/services/atomic-write.d.ts +2 -0
- package/dist/services/atomic-write.js +12 -1
- package/dist/services/code-review/format.d.ts +4 -1
- package/dist/services/code-review/format.js +5 -1
- package/dist/services/code-review/runner.d.ts +2 -2
- package/dist/services/code-review/runner.js +86 -64
- package/dist/services/code-review/snapshot.d.ts +9 -9
- package/dist/services/code-review/snapshot.js +182 -166
- package/dist/services/compact/auto-compact.d.ts +21 -6
- package/dist/services/compact/auto-compact.js +148 -22
- package/dist/services/compact/background-candidate.d.ts +33 -0
- package/dist/services/compact/background-candidate.js +184 -0
- package/dist/services/compact/compact.d.ts +4 -1
- package/dist/services/compact/compact.js +30 -3
- package/dist/services/compact/coordinator.d.ts +10 -4
- package/dist/services/compact/coordinator.js +17 -7
- package/dist/services/compact/summary-generator.d.ts +4 -2
- package/dist/services/compact/summary-generator.js +17 -3
- package/dist/services/config.d.ts +5 -5
- package/dist/services/config.js +30 -45
- package/dist/services/doctor.js +85 -13
- package/dist/services/effort.d.ts +5 -5
- package/dist/services/effort.js +5 -11
- package/dist/services/file-lock.d.ts +9 -3
- package/dist/services/file-lock.js +92 -26
- package/dist/services/global-config.d.ts +26 -56
- package/dist/services/global-config.js +213 -183
- package/dist/services/llm.d.ts +40 -4
- package/dist/services/llm.js +164 -45
- package/dist/services/model-client-pool.d.ts +15 -9
- package/dist/services/model-client-pool.js +62 -33
- package/dist/services/model-context.d.ts +2 -1
- package/dist/services/model-context.js +15 -9
- package/dist/services/model-registry.d.ts +4 -15
- package/dist/services/model-registry.js +32 -101
- package/dist/services/provider-diagnostics.d.ts +7 -0
- package/dist/services/provider-diagnostics.js +9 -10
- package/dist/services/provider-resilience/coordinator.d.ts +1 -1
- package/dist/services/provider-resilience/coordinator.js +10 -6
- package/dist/services/provider-resilience/request-gate.d.ts +3 -0
- package/dist/services/provider-resilience/request-gate.js +29 -18
- package/dist/services/provider-resilience/types.d.ts +2 -0
- package/dist/services/session-storage.d.ts +7 -10
- package/dist/services/session-storage.js +57 -30
- package/dist/services/settings-coordinator.d.ts +0 -6
- package/dist/services/settings-coordinator.js +19 -56
- package/dist/services/settings-document-repository.d.ts +3 -10
- package/dist/services/settings-document-repository.js +7 -85
- package/dist/services/usage-state.d.ts +3 -3
- package/dist/services/usage-state.js +11 -42
- package/dist/terminal-ui/answer-format.d.ts +14 -0
- package/dist/terminal-ui/answer-format.js +119 -0
- package/dist/terminal-ui/launch.d.ts +7 -6
- package/dist/terminal-ui/launch.js +160 -70
- package/dist/terminal-ui/output-queue.d.ts +2 -1
- package/dist/terminal-ui/output-queue.js +1 -1
- package/dist/terminal-ui/raw-editor.d.ts +2 -1
- package/dist/terminal-ui/raw-editor.js +56 -15
- package/dist/tools/core/edit-file.js +2 -0
- package/dist/tools/core/write-file.js +5 -0
- package/dist/tools/lsp.d.ts +16 -1
- package/dist/tools/lsp.js +60 -19
- package/dist/tools/sandbox.d.ts +1 -1
- package/dist/tools/sandbox.js +3 -16
- package/dist/tools/todo.d.ts +4 -2
- package/dist/tools/todo.js +76 -31
- package/dist/tui-core/input-parser.d.ts +1 -0
- package/dist/tui-core/input-parser.js +6 -0
- package/dist/tui-core/style.d.ts +1 -8
- package/dist/tui-core/style.js +3 -110
- package/dist/tui-ui/chrome-view-model.d.ts +1 -1
- package/dist/tui-ui/chrome-view-model.js +22 -27
- package/dist/tui-ui/launch.js +14 -14
- package/dist/tui-ui/layout.d.ts +5 -7
- package/dist/tui-ui/layout.js +129 -124
- package/dist/tui-ui/runner.d.ts +11 -12
- package/dist/tui-ui/runner.js +88 -67
- package/dist/tui-ui/state.d.ts +0 -11
- package/dist/tui-ui/state.js +22 -33
- package/dist/tui-ui/terminal-image.js +22 -4
- package/dist/tui-ui/transcript-inspector-layout.js +6 -3
- package/dist/tui-ui/transcript-inspector.d.ts +1 -0
- package/dist/tui-ui/transcript-inspector.js +7 -1
- package/dist/tui-ui/transcript-layout.js +42 -6
- package/dist/utils/terminal-text.d.ts +11 -0
- package/dist/utils/terminal-text.js +114 -0
- package/docs/cli-guide.md +562 -0
- package/docs/orion.example.yaml +42 -0
- package/docs/readme.md +12 -57
- package/npm-shrinkwrap.json +484 -1855
- package/package.json +13 -63
- package/dist/migration/command.d.ts +0 -9
- package/dist/migration/command.js +0 -100
- package/dist/migration/index.d.ts +0 -7
- package/dist/migration/index.js +0 -14
- package/dist/migration/migrate.d.ts +0 -19
- package/dist/migration/migrate.js +0 -406
- package/dist/migration/types.d.ts +0 -55
- package/dist/migration/types.js +0 -6
- package/dist/services/tool-allowlist.d.ts +0 -110
- package/dist/services/tool-allowlist.js +0 -299
- package/dist/services/yaml-config.d.ts +0 -57
- package/dist/services/yaml-config.js +0 -178
- package/dist/web/cli-options.d.ts +0 -17
- package/dist/web/cli-options.js +0 -51
- package/dist/web/code-review-run-service.d.ts +0 -68
- package/dist/web/code-review-run-service.js +0 -228
- package/dist/web/context-text.d.ts +0 -17
- package/dist/web/context-text.js +0 -40
- package/dist/web/errors.d.ts +0 -6
- package/dist/web/errors.js +0 -13
- package/dist/web/event-hub.d.ts +0 -45
- package/dist/web/event-hub.js +0 -370
- package/dist/web/file-read-service.d.ts +0 -101
- package/dist/web/file-read-service.js +0 -593
- package/dist/web/file-write-service.d.ts +0 -16
- package/dist/web/file-write-service.js +0 -103
- package/dist/web/git-compare-service.d.ts +0 -45
- package/dist/web/git-compare-service.js +0 -160
- package/dist/web/git-diff-document.d.ts +0 -102
- package/dist/web/git-diff-document.js +0 -258
- package/dist/web/git-file-source.d.ts +0 -25
- package/dist/web/git-file-source.js +0 -21
- package/dist/web/git-history-service.d.ts +0 -151
- package/dist/web/git-history-service.js +0 -619
- package/dist/web/git-index-transaction.d.ts +0 -45
- package/dist/web/git-index-transaction.js +0 -174
- package/dist/web/git-patch-builder.d.ts +0 -30
- package/dist/web/git-patch-builder.js +0 -138
- package/dist/web/git-read-model-service.d.ts +0 -452
- package/dist/web/git-read-model-service.js +0 -1833
- package/dist/web/git-version-service.d.ts +0 -79
- package/dist/web/git-version-service.js +0 -279
- package/dist/web/host-daemon.d.ts +0 -70
- package/dist/web/host-daemon.js +0 -237
- package/dist/web/index.d.ts +0 -6
- package/dist/web/index.js +0 -28
- package/dist/web/launch.d.ts +0 -12
- package/dist/web/launch.js +0 -89
- package/dist/web/native-directory-picker.d.ts +0 -63
- package/dist/web/native-directory-picker.js +0 -169
- package/dist/web/protocol.d.ts +0 -705
- package/dist/web/protocol.js +0 -639
- package/dist/web/review-service.d.ts +0 -22
- package/dist/web/review-service.js +0 -68
- package/dist/web/server.d.ts +0 -20
- package/dist/web/server.js +0 -1453
- package/dist/web/session-runtime-registry.d.ts +0 -138
- package/dist/web/session-runtime-registry.js +0 -471
- package/dist/web/terminal-manager.d.ts +0 -156
- package/dist/web/terminal-manager.js +0 -779
- package/dist/web/terminal-server.d.ts +0 -8
- package/dist/web/terminal-server.js +0 -304
- package/dist/web/workbench-controller.d.ts +0 -395
- package/dist/web/workbench-controller.js +0 -3077
- package/dist/web/workspace-discovery.d.ts +0 -92
- package/dist/web/workspace-discovery.js +0 -324
- package/dist/web/workspace-mutation-arbiter.d.ts +0 -54
- package/dist/web/workspace-mutation-arbiter.js +0 -267
- package/dist/web/workspace-open-telemetry.d.ts +0 -55
- package/dist/web/workspace-open-telemetry.js +0 -73
- package/dist/web-client/assets/FilesPanel-iBYj9ZRf.js +0 -1
- package/dist/web-client/assets/GitPanel-D33R_bZr.js +0 -4
- package/dist/web-client/assets/ReviewPanel-C_0upsDk.js +0 -6
- package/dist/web-client/assets/TerminalPanel-C7A8dMNf.js +0 -23
- package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +0 -1
- package/dist/web-client/assets/index-BaOxrwGB.css +0 -1
- package/dist/web-client/assets/index-CqCgJ2ov.js +0 -20
- package/dist/web-client/assets/useAutoNotice-C1qM-_Sg.js +0 -1
- package/dist/web-client/favicon.svg +0 -9
- package/dist/web-client/index.html +0 -17
- package/docs/architecture/agent-mode-permission-contract.md +0 -87
- package/docs/architecture/v0.3.0-web-api.yaml +0 -1340
- package/docs/architecture/v0.3.1-web-api.yaml +0 -2338
- package/docs/architecture/v0.3.2-web-api.yaml +0 -3029
- package/docs/architecture/v0.3.3-web-api.yaml +0 -3205
- package/docs/architecture/v0.3.4-stabilization-contract.md +0 -32
- package/docs/migration/v0.1.9-to-v0.2.0.md +0 -98
- package/docs/migration/v0.2.2-to-v0.3.0-settings.md +0 -114
- package/docs/migration/v0.2.2-to-v0.3.0.md +0 -55
- package/docs/migration/v0.3.0-to-v0.3.1.md +0 -88
- package/docs/migration/v0.3.1-to-v0.3.2.md +0 -94
- package/docs/migration/v0.3.2-to-v0.3.3.md +0 -62
- package/docs/migration/v0.3.3-to-v0.3.4.md +0 -36
- package/docs/orion.example.json +0 -86
- package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +0 -1234
- package/docs/plan/v0.2.0-release-checklist.md +0 -91
- package/docs/plan/v0.3.0-node-runtime-compatibility-plan.md +0 -57
- package/docs/plan/v0.3.0-settings-integration-plan.md +0 -740
- package/docs/plan/v0.3.0-web-workbench-plan.md +0 -376
- package/docs/plan/v0.3.1-web-workbench-professional-shell-plan.md +0 -848
- package/docs/plan/v0.3.2-web-workbench-layout-and-composer-plan.md +0 -869
- package/docs/plan/v0.3.3-plan.md +0 -1113
- package/docs/plan/v0.3.4-stabilization-plan.md +0 -89
- package/docs/test/v0.3.1-web-workbench-e2e-plan.md +0 -140
- package/docs/test/v0.3.2-web-workbench-e2e-plan.md +0 -100
- package/docs/test/v0.3.3-web-workbench-e2e-plan.md +0 -79
- package/docs/test/v0.3.4-stabilization-e2e-plan.md +0 -54
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RsiTurnEvidenceV1 } from './contracts';
|
|
2
|
+
export interface RsiWorkerInput {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly skill: string;
|
|
5
|
+
readonly expected: string | null;
|
|
6
|
+
readonly prompt: string;
|
|
7
|
+
readonly baseCommit: string;
|
|
8
|
+
readonly timeoutMs: number;
|
|
9
|
+
}
|
|
10
|
+
export interface RsiWorkerResult {
|
|
11
|
+
readonly version: 1;
|
|
12
|
+
readonly evidence: RsiTurnEvidenceV1;
|
|
13
|
+
readonly requests: number;
|
|
14
|
+
readonly totalTokens: number;
|
|
15
|
+
readonly printExitCode: number;
|
|
16
|
+
readonly hitBudget: boolean;
|
|
17
|
+
readonly digest: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=evaluation-worker.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const launch_1 = require("../../print-ui/launch");
|
|
4
|
+
const usage_state_1 = require("../../services/usage-state");
|
|
5
|
+
const product_bootstrap_1 = require("../product-bootstrap");
|
|
6
|
+
const legacy_thread_materializer_1 = require("../legacy-thread-materializer");
|
|
7
|
+
const evaluation_suite_1 = require("./evaluation-suite");
|
|
8
|
+
const receipt_1 = require("./receipt");
|
|
9
|
+
const skill_state_1 = require("./skill-state");
|
|
10
|
+
const trajectory_1 = require("./trajectory");
|
|
11
|
+
const turn_commit_1 = require("../turn-commit");
|
|
12
|
+
async function main() {
|
|
13
|
+
const [input, output] = process.argv.slice(2);
|
|
14
|
+
const request = (0, receipt_1.readRsiJson)(input);
|
|
15
|
+
setTimeout(() => process.exit(124), request.timeoutMs).unref();
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
const expected = await (0, skill_state_1.inspectRsiSkill)(cwd, request, request.expected ?? undefined);
|
|
18
|
+
const kernel = (0, product_bootstrap_1.createWorkspaceRuntimeKernelV1)({ cwd, toolNames: evaluation_suite_1.RSI_EVALUATION_TOOLS });
|
|
19
|
+
let printExitCode;
|
|
20
|
+
try {
|
|
21
|
+
const runtime = await (0, product_bootstrap_1.createProductUiRuntime)({ cwd, workspaceRuntimeKernel: kernel });
|
|
22
|
+
printExitCode = await (0, launch_1.launchPrintMode)(runtime, request.prompt, { outputFormat: 'json' });
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
kernel.releaseOwner();
|
|
26
|
+
}
|
|
27
|
+
const sessions = Object.keys((0, legacy_thread_materializer_1.loadThreadCutoverIndexV1)(cwd).sessions);
|
|
28
|
+
if (sessions.length !== 1)
|
|
29
|
+
throw new Error('RSI needs exactly one isolated Session.');
|
|
30
|
+
const [sessionId] = sessions;
|
|
31
|
+
const opened = (0, legacy_thread_materializer_1.openSessionStorageV1)(cwd, sessionId);
|
|
32
|
+
if (!('store' in opened))
|
|
33
|
+
throw new Error('RSI evaluation Session did not persist a Thread.');
|
|
34
|
+
const turns = Object.values(opened.store.loadProjection().turns);
|
|
35
|
+
if (turns.length !== 1)
|
|
36
|
+
throw new Error('RSI needs exactly one isolated turn.');
|
|
37
|
+
const [turn] = turns;
|
|
38
|
+
if (!turn.commit)
|
|
39
|
+
throw new Error('RSI evaluation turn did not commit.');
|
|
40
|
+
const commit = (0, turn_commit_1.parseTurnCommitV1)(turn.commit.receipt);
|
|
41
|
+
const hitBudget = commit.outcome !== undefined &&
|
|
42
|
+
JSON.parse(commit.outcome).finishReason === 'budget_exceeded';
|
|
43
|
+
const [evidence] = (0, trajectory_1.collectRsiEvidence)({
|
|
44
|
+
version: 1,
|
|
45
|
+
repository: cwd,
|
|
46
|
+
baseCommit: request.baseCommit,
|
|
47
|
+
turns: [
|
|
48
|
+
{ sessionId, turnId: turn.turnId, category: 'missing_verification', result: 'accepted' },
|
|
49
|
+
],
|
|
50
|
+
}, expected);
|
|
51
|
+
const usage = (0, usage_state_1.loadUsageLedger)();
|
|
52
|
+
(0, receipt_1.writeRsiState)(output, {
|
|
53
|
+
version: 1,
|
|
54
|
+
evidence,
|
|
55
|
+
requests: Math.max(usage.length, commit.capabilityReceiptDigests.length),
|
|
56
|
+
totalTokens: usage.reduce((total, entry) => total + entry.totalTokens, 0),
|
|
57
|
+
printExitCode,
|
|
58
|
+
hitBudget,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (require.main === module) {
|
|
62
|
+
void main().then(() => process.exit(0), () => process.exit(1));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=evaluation-worker.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type RsiEvaluationTask } from './evaluation-suite';
|
|
2
|
+
type Arm = 'baseline' | 'candidate';
|
|
3
|
+
type Verdict = 'screened_out' | 'improved' | 'unchanged' | 'regressed' | 'inconclusive';
|
|
4
|
+
export interface RsiArmResult {
|
|
5
|
+
readonly elapsedMs: number;
|
|
6
|
+
readonly score: 'pass' | 'fail' | 'unknown';
|
|
7
|
+
readonly reason?: 'runtime' | 'cancelled' | 'budget' | 'skill_unverified' | 'no_usage' | 'check_failed';
|
|
8
|
+
readonly guardViolation?: boolean;
|
|
9
|
+
readonly requests?: number;
|
|
10
|
+
readonly totalTokens?: number;
|
|
11
|
+
readonly expectedSkill?: string | null;
|
|
12
|
+
readonly proofDigest?: string;
|
|
13
|
+
readonly promptDigests?: readonly string[];
|
|
14
|
+
readonly tools?: readonly {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly success: boolean;
|
|
17
|
+
}[];
|
|
18
|
+
readonly matched?: number;
|
|
19
|
+
readonly expected?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface RsiPair {
|
|
22
|
+
readonly taskId: string;
|
|
23
|
+
readonly split: RsiEvaluationTask['split'];
|
|
24
|
+
readonly category: RsiEvaluationTask['category'];
|
|
25
|
+
readonly repeat: number;
|
|
26
|
+
readonly order: readonly Arm[];
|
|
27
|
+
readonly state: 'running' | 'complete' | 'indeterminate';
|
|
28
|
+
readonly owner?: number;
|
|
29
|
+
readonly arms: Partial<Record<Arm, RsiArmResult>>;
|
|
30
|
+
}
|
|
31
|
+
interface RsiComparisonState {
|
|
32
|
+
readonly version: 1;
|
|
33
|
+
readonly proposalDigest: string;
|
|
34
|
+
readonly candidateDigest: string;
|
|
35
|
+
readonly suitePath: string;
|
|
36
|
+
readonly suiteDigest: string;
|
|
37
|
+
readonly executionProfileDigest: string;
|
|
38
|
+
readonly pairs: readonly RsiPair[];
|
|
39
|
+
readonly phase: 'evaluating' | 'cancelled' | 'awaiting_review' | 'evaluated';
|
|
40
|
+
readonly verdict?: Verdict;
|
|
41
|
+
}
|
|
42
|
+
export interface RsiComparisonReceiptV1 extends RsiComparisonState {
|
|
43
|
+
readonly digest: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function readRsiComparison(directory: string, proposalDigest: string): RsiComparisonReceiptV1 | undefined;
|
|
46
|
+
export declare function judgeRsiPairs(pairs: readonly RsiPair[]): Verdict;
|
|
47
|
+
export declare function evaluateRsi(output: string, suiteFile: string | undefined, signal: AbortSignal): Promise<RsiComparisonReceiptV1>;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=evaluation.d.ts.map
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readRsiComparison = readRsiComparison;
|
|
4
|
+
exports.judgeRsiPairs = judgeRsiPairs;
|
|
5
|
+
exports.evaluateRsi = evaluateRsi;
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const os_1 = require("os");
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const util_1 = require("util");
|
|
12
|
+
const file_lock_1 = require("../../services/file-lock");
|
|
13
|
+
const canonical_1 = require("../protocol/canonical");
|
|
14
|
+
const evaluation_suite_1 = require("./evaluation-suite");
|
|
15
|
+
const proposal_1 = require("./proposal");
|
|
16
|
+
const receipt_1 = require("./receipt");
|
|
17
|
+
const runChild = (0, util_1.promisify)(child_process_1.execFile);
|
|
18
|
+
function readRsiComparison(directory, proposalDigest) {
|
|
19
|
+
const receipt = (0, receipt_1.readRsiState)((0, path_1.join)(directory, 'comparison.json'));
|
|
20
|
+
if (receipt && receipt.proposalDigest !== proposalDigest) {
|
|
21
|
+
throw new Error('RSI comparison does not belong to this proposal.');
|
|
22
|
+
}
|
|
23
|
+
return receipt;
|
|
24
|
+
}
|
|
25
|
+
function installedRuntimeDigest() {
|
|
26
|
+
const root = (0, path_1.join)(__dirname, '..', '..');
|
|
27
|
+
const hash = (0, crypto_1.createHash)('sha256');
|
|
28
|
+
const visit = (base) => {
|
|
29
|
+
for (const entry of (0, fs_1.readdirSync)((0, path_1.join)(root, base), { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
30
|
+
const path = (0, path_1.join)(base, entry.name);
|
|
31
|
+
if (entry.isDirectory())
|
|
32
|
+
visit(path);
|
|
33
|
+
else if (entry.isFile() && /\.(?:js|json|md)$/u.test(path)) {
|
|
34
|
+
const file = (0, crypto_1.createHash)('sha256')
|
|
35
|
+
.update((0, fs_1.readFileSync)((0, path_1.join)(root, path)))
|
|
36
|
+
.digest('hex');
|
|
37
|
+
hash.update(`${path}\0${file}\n`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
visit('');
|
|
42
|
+
return hash.digest('hex');
|
|
43
|
+
}
|
|
44
|
+
function fixtureSnapshot(root, relative = '', depth = 0, files = new Map()) {
|
|
45
|
+
if (depth > 12)
|
|
46
|
+
throw new Error('RSI fixture exceeded maximum depth.');
|
|
47
|
+
for (const name of (0, fs_1.readdirSync)((0, path_1.join)(root, relative))) {
|
|
48
|
+
const path = relative ? `${relative}/${name}` : name;
|
|
49
|
+
const full = (0, path_1.join)(root, path);
|
|
50
|
+
const entry = (0, fs_1.lstatSync)(full);
|
|
51
|
+
if (entry.isDirectory()) {
|
|
52
|
+
fixtureSnapshot(root, path, depth + 1, files);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
if (!entry.isFile() || files.size >= 80 || entry.size > 64 * 1024) {
|
|
56
|
+
throw new Error('RSI fixture contains an unexpected file or exceeded its limits.');
|
|
57
|
+
}
|
|
58
|
+
files.set(path, (0, receipt_1.readRsiFile)(full));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return files;
|
|
62
|
+
}
|
|
63
|
+
async function runArm(task, suite, input, signal) {
|
|
64
|
+
const started = Date.now();
|
|
65
|
+
const timing = () => ({ elapsedMs: Date.now() - started });
|
|
66
|
+
const sandbox = (0, fs_1.realpathSync)((0, fs_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), 'orion-rsi-arm-')));
|
|
67
|
+
try {
|
|
68
|
+
const cwd = (0, path_1.join)(sandbox, 'fixture');
|
|
69
|
+
const config = (0, path_1.join)(sandbox, 'profile');
|
|
70
|
+
(0, fs_1.mkdirSync)(cwd, { mode: 0o700 });
|
|
71
|
+
(0, fs_1.mkdirSync)(config, { mode: 0o700 });
|
|
72
|
+
const write = (file, content) => {
|
|
73
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(file), { recursive: true, mode: 0o700 });
|
|
74
|
+
(0, fs_1.writeFileSync)(file, content, { mode: 0o600 });
|
|
75
|
+
};
|
|
76
|
+
for (const [path, content] of Object.entries(task.files))
|
|
77
|
+
write((0, path_1.join)(cwd, path), content);
|
|
78
|
+
if (input.expected !== null)
|
|
79
|
+
write((0, path_1.join)(cwd, input.path), input.expected);
|
|
80
|
+
const before = fixtureSnapshot(cwd);
|
|
81
|
+
write((0, path_1.join)(config, 'orion.yaml'), JSON.stringify({
|
|
82
|
+
schemaVersion: 1,
|
|
83
|
+
providers: [
|
|
84
|
+
{
|
|
85
|
+
id: 'rsi-local',
|
|
86
|
+
baseUrl: suite.endpoint,
|
|
87
|
+
protocol: 'openai-completions',
|
|
88
|
+
apiKey: 'orion-rsi-local',
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
models: [
|
|
92
|
+
{
|
|
93
|
+
id: 'rsi-evaluation',
|
|
94
|
+
provider: 'rsi-local',
|
|
95
|
+
model: suite.model,
|
|
96
|
+
maxOutputTokens: Math.min(2048, Math.floor(suite.maxTokens / suite.maxRequests)),
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
defaultModel: 'rsi-evaluation',
|
|
100
|
+
subagents: { mode: 'off' },
|
|
101
|
+
agentLoop: {
|
|
102
|
+
continuation: 'manual',
|
|
103
|
+
budget: {
|
|
104
|
+
maxLlmRequestsPerUserTurn: suite.maxRequests,
|
|
105
|
+
maxToolCallsPerUserTurn: suite.maxTools,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
}));
|
|
109
|
+
const inputPath = (0, path_1.join)(sandbox, 'input.json');
|
|
110
|
+
const outputPath = (0, path_1.join)(sandbox, 'arm.json');
|
|
111
|
+
write(inputPath, JSON.stringify(input));
|
|
112
|
+
const inherited = Object.fromEntries(Object.entries(process.env).filter(([key]) => ['PATH', 'Path', 'DEVELOPER_DIR', 'SystemRoot', 'WINDIR', 'TMPDIR', 'TEMP', 'TMP'].includes(key)));
|
|
113
|
+
let processFailed = false;
|
|
114
|
+
try {
|
|
115
|
+
await runChild(process.execPath, [(0, path_1.join)(__dirname, 'evaluation-worker.js'), inputPath, outputPath], {
|
|
116
|
+
cwd,
|
|
117
|
+
signal,
|
|
118
|
+
timeout: suite.timeoutMs,
|
|
119
|
+
killSignal: 'SIGKILL',
|
|
120
|
+
maxBuffer: 2 * 1024 * 1024,
|
|
121
|
+
env: {
|
|
122
|
+
...inherited,
|
|
123
|
+
HOME: sandbox,
|
|
124
|
+
USERPROFILE: sandbox,
|
|
125
|
+
NO_COLOR: '1',
|
|
126
|
+
ORION_CODE_CONFIG_DIR: config,
|
|
127
|
+
ORION_CODE_DISABLE_ENV_FILES: '1',
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
processFailed = true;
|
|
133
|
+
}
|
|
134
|
+
let after;
|
|
135
|
+
try {
|
|
136
|
+
after = fixtureSnapshot(cwd);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return { ...timing(), score: 'fail', guardViolation: true, reason: 'check_failed' };
|
|
140
|
+
}
|
|
141
|
+
const checks = Object.entries(task.expected);
|
|
142
|
+
const changed = [...new Set([...before.keys(), ...after.keys()])].filter(path => before.get(path) !== after.get(path));
|
|
143
|
+
const guardViolation = changed.some(path => !Object.prototype.hasOwnProperty.call(task.expected, path));
|
|
144
|
+
const matched = checks.filter(([path, content]) => after.get(path) === content).length;
|
|
145
|
+
const report = (0, receipt_1.readRsiState)(outputPath);
|
|
146
|
+
const proof = report?.evidence.skillProof;
|
|
147
|
+
const tools = report?.evidence.toolReceipts.map(({ name, success }) => ({ name, success })) ?? [];
|
|
148
|
+
const result = {
|
|
149
|
+
...timing(),
|
|
150
|
+
matched,
|
|
151
|
+
expected: checks.length,
|
|
152
|
+
guardViolation,
|
|
153
|
+
tools,
|
|
154
|
+
requests: report?.requests ?? 0,
|
|
155
|
+
totalTokens: report?.totalTokens ?? 0,
|
|
156
|
+
...(proof
|
|
157
|
+
? { expectedSkill: proof.descriptorDigest, promptDigests: proof.promptDigests }
|
|
158
|
+
: {}),
|
|
159
|
+
...(report ? { proofDigest: report.evidence.turnCommitDigest } : {}),
|
|
160
|
+
};
|
|
161
|
+
if (guardViolation)
|
|
162
|
+
return { ...result, score: 'fail', reason: 'check_failed' };
|
|
163
|
+
if (processFailed || !report) {
|
|
164
|
+
return { ...result, score: 'unknown', reason: signal.aborted ? 'cancelled' : 'runtime' };
|
|
165
|
+
}
|
|
166
|
+
if (!proof?.verified)
|
|
167
|
+
return { ...result, score: 'unknown', reason: 'skill_unverified' };
|
|
168
|
+
if (report.requests === 0 || report.totalTokens === 0)
|
|
169
|
+
return { ...result, score: 'unknown', reason: 'no_usage' };
|
|
170
|
+
if (report.hitBudget ||
|
|
171
|
+
report.requests > suite.maxRequests ||
|
|
172
|
+
report.totalTokens > suite.maxTokens ||
|
|
173
|
+
tools.length > suite.maxTools) {
|
|
174
|
+
return { ...result, score: 'unknown', reason: 'budget' };
|
|
175
|
+
}
|
|
176
|
+
if (matched !== checks.length ||
|
|
177
|
+
report.printExitCode !== 0 ||
|
|
178
|
+
report.evidence.terminal !== 'completed' ||
|
|
179
|
+
tools.some(tool => !tool.success))
|
|
180
|
+
return { ...result, score: 'fail', reason: 'check_failed' };
|
|
181
|
+
return { ...result, score: 'pass' };
|
|
182
|
+
}
|
|
183
|
+
finally {
|
|
184
|
+
(0, fs_1.rmSync)(sandbox, { recursive: true, force: true });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function judgeRsiPairs(pairs) {
|
|
188
|
+
if (pairs.some(pair => pair.arms.candidate?.guardViolation ||
|
|
189
|
+
(pair.arms.baseline?.score === 'pass' && pair.arms.candidate?.score === 'fail'))) {
|
|
190
|
+
return 'regressed';
|
|
191
|
+
}
|
|
192
|
+
if (pairs.some(pair => pair.state !== 'complete' ||
|
|
193
|
+
!pair.arms.baseline ||
|
|
194
|
+
pair.arms.baseline.score === 'unknown' ||
|
|
195
|
+
!pair.arms.candidate ||
|
|
196
|
+
pair.arms.candidate.score === 'unknown'))
|
|
197
|
+
return 'inconclusive';
|
|
198
|
+
const delta = (pair) => (pair.arms.candidate?.tools?.length ?? 0) - (pair.arms.baseline?.tools?.length ?? 0);
|
|
199
|
+
const local = pairs
|
|
200
|
+
.filter(pair => pair.category === 'local_edit_cost')
|
|
201
|
+
.map(delta)
|
|
202
|
+
.sort((a, b) => a - b);
|
|
203
|
+
if ((local.length > 0 &&
|
|
204
|
+
(local[Math.floor((local.length - 1) / 2)] + local[Math.floor(local.length / 2)]) / 2 > 1) ||
|
|
205
|
+
pairs.some(pair => pair.category === 'missing_verification' && delta(pair) > 0))
|
|
206
|
+
return 'regressed';
|
|
207
|
+
return pairs.some(pair => pair.arms.baseline?.score === 'fail' && pair.arms.candidate?.score === 'pass')
|
|
208
|
+
? 'improved'
|
|
209
|
+
: 'unchanged';
|
|
210
|
+
}
|
|
211
|
+
function isAlive(pid) {
|
|
212
|
+
try {
|
|
213
|
+
process.kill(pid, 0);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
return error.code !== 'ESRCH';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async function evaluateRsi(output, suiteFile, signal) {
|
|
221
|
+
const directory = (0, fs_1.realpathSync)((0, path_1.resolve)(output));
|
|
222
|
+
const receipt = (0, receipt_1.readRsiReceipt)(directory);
|
|
223
|
+
const candidate = receipt.proposal;
|
|
224
|
+
if (!('patch' in candidate))
|
|
225
|
+
throw new Error('This RSI proposal has no Skill candidate.');
|
|
226
|
+
const target = (0, path_1.join)(directory, 'comparison.json');
|
|
227
|
+
const existing = readRsiComparison(directory, receipt.digest);
|
|
228
|
+
const suitePath = suiteFile ? (0, path_1.resolve)(suiteFile) : existing?.suitePath;
|
|
229
|
+
if (!suitePath)
|
|
230
|
+
throw new Error('Supply --suite to start RSI evaluation.');
|
|
231
|
+
const suite = (0, evaluation_suite_1.parseRsiSuite)((0, receipt_1.readRsiJson)(suitePath));
|
|
232
|
+
const suiteDigest = (0, canonical_1.digestRuntimeValue)(suite);
|
|
233
|
+
// Tool manifest and runtime identity are frozen for resumption with the same install.
|
|
234
|
+
const executionProfileDigest = (0, canonical_1.digestRuntimeValue)({
|
|
235
|
+
node: process.version,
|
|
236
|
+
platform: process.platform,
|
|
237
|
+
arch: process.arch,
|
|
238
|
+
runtime: installedRuntimeDigest(),
|
|
239
|
+
tools: evaluation_suite_1.RSI_EVALUATION_TOOLS,
|
|
240
|
+
});
|
|
241
|
+
const { before, after } = await (0, proposal_1.resolveRsiCandidate)(receipt.repository, candidate);
|
|
242
|
+
const initial = {
|
|
243
|
+
version: 1,
|
|
244
|
+
proposalDigest: receipt.digest,
|
|
245
|
+
candidateDigest: candidate.candidateContentDigest,
|
|
246
|
+
suitePath,
|
|
247
|
+
suiteDigest,
|
|
248
|
+
executionProfileDigest,
|
|
249
|
+
pairs: [],
|
|
250
|
+
phase: 'evaluating',
|
|
251
|
+
};
|
|
252
|
+
const read = () => {
|
|
253
|
+
const current = readRsiComparison(directory, receipt.digest);
|
|
254
|
+
if (current &&
|
|
255
|
+
(current.suiteDigest !== suiteDigest ||
|
|
256
|
+
current.candidateDigest !== initial.candidateDigest ||
|
|
257
|
+
current.executionProfileDigest !== executionProfileDigest))
|
|
258
|
+
throw new Error('RSI suite, candidate, or execution profile changed. Use a new run.');
|
|
259
|
+
return current;
|
|
260
|
+
};
|
|
261
|
+
const save = (state, pairs, phase, verdict) => {
|
|
262
|
+
const { version, proposalDigest, candidateDigest, suitePath, suiteDigest, executionProfileDigest, } = state;
|
|
263
|
+
return (0, receipt_1.writeRsiState)(target, {
|
|
264
|
+
version,
|
|
265
|
+
proposalDigest,
|
|
266
|
+
candidateDigest,
|
|
267
|
+
suitePath,
|
|
268
|
+
suiteDigest,
|
|
269
|
+
executionProfileDigest,
|
|
270
|
+
pairs,
|
|
271
|
+
phase,
|
|
272
|
+
...(verdict ? { verdict } : {}),
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
for (const task of suite.tasks) {
|
|
276
|
+
for (let repeat = 0; repeat < suite.repeats; repeat++) {
|
|
277
|
+
const next = (0, file_lock_1.withFileLockSync)(target, () => {
|
|
278
|
+
const state = read() ?? initial;
|
|
279
|
+
if (state.verdict)
|
|
280
|
+
return undefined;
|
|
281
|
+
const active = state.pairs.find(pair => pair.state === 'running');
|
|
282
|
+
if (active?.owner && isAlive(active.owner))
|
|
283
|
+
throw new Error('RSI evaluation is already running.');
|
|
284
|
+
const pairs = state.pairs.map(pair => pair.state === 'running'
|
|
285
|
+
? { ...pair, state: 'indeterminate', owner: undefined }
|
|
286
|
+
: pair);
|
|
287
|
+
if (signal.aborted) {
|
|
288
|
+
save(state, pairs, 'cancelled');
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
if (task.split === 'holdout') {
|
|
292
|
+
const screen = judgeRsiPairs(pairs.filter(pair => pair.split === 'development'));
|
|
293
|
+
if (screen === 'inconclusive' || screen === 'regressed') {
|
|
294
|
+
save(state, pairs, 'evaluated', screen === 'inconclusive' ? screen : 'screened_out');
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (pairs.some(pair => pair.taskId === task.id && pair.repeat === repeat))
|
|
299
|
+
return undefined;
|
|
300
|
+
const pair = {
|
|
301
|
+
taskId: task.id,
|
|
302
|
+
repeat,
|
|
303
|
+
split: task.split,
|
|
304
|
+
category: task.category,
|
|
305
|
+
state: 'running',
|
|
306
|
+
owner: process.pid,
|
|
307
|
+
order: pairs.length % 2 === 0 ? ['baseline', 'candidate'] : ['candidate', 'baseline'],
|
|
308
|
+
arms: {},
|
|
309
|
+
};
|
|
310
|
+
save(state, [...pairs, pair], 'evaluating');
|
|
311
|
+
return pair;
|
|
312
|
+
});
|
|
313
|
+
if (!next)
|
|
314
|
+
continue;
|
|
315
|
+
for (const arm of next.order) {
|
|
316
|
+
if (signal.aborted)
|
|
317
|
+
break;
|
|
318
|
+
const measured = await runArm(task, suite, {
|
|
319
|
+
skill: candidate.skill,
|
|
320
|
+
path: candidate.path,
|
|
321
|
+
baseCommit: candidate.baseCommit,
|
|
322
|
+
timeoutMs: suite.timeoutMs,
|
|
323
|
+
expected: (arm === 'baseline' ? before : after) ?? null,
|
|
324
|
+
prompt: `$${candidate.skill} ${task.prompt}`,
|
|
325
|
+
}, signal);
|
|
326
|
+
(0, file_lock_1.withFileLockSync)(target, () => {
|
|
327
|
+
const state = read();
|
|
328
|
+
save(state, state.pairs.map(pair => pair.owner === process.pid && pair.state === 'running'
|
|
329
|
+
? { ...pair, arms: { ...pair.arms, [arm]: measured } }
|
|
330
|
+
: pair), 'evaluating');
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
(0, file_lock_1.withFileLockSync)(target, () => {
|
|
334
|
+
const state = read();
|
|
335
|
+
save(state, state.pairs.map(pair => pair.owner === process.pid && pair.state === 'running'
|
|
336
|
+
? { ...pair, state: signal.aborted ? 'indeterminate' : 'complete', owner: undefined }
|
|
337
|
+
: pair), signal.aborted ? 'cancelled' : 'evaluating');
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return (0, file_lock_1.withFileLockSync)(target, () => {
|
|
342
|
+
const state = read();
|
|
343
|
+
if (state.verdict || signal.aborted)
|
|
344
|
+
return state;
|
|
345
|
+
if (state.pairs.some(pair => pair.state === 'running'))
|
|
346
|
+
throw new Error('RSI evaluation is already running.');
|
|
347
|
+
const verdict = judgeRsiPairs(state.pairs.filter(pair => pair.split === 'holdout'));
|
|
348
|
+
return save(state, state.pairs, verdict === 'improved' ? 'awaiting_review' : 'evaluated', verdict);
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=evaluation.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { RsiCategory, RsiTurnEvidenceV1 } from './contracts';
|
|
2
|
+
type LifecyclePhase = 'applying' | 'applied_to_review' | 'accepted' | 'observed' | 'rolling_back' | 'rollback_pending_commit' | 'rolled_back' | 'rollback_verified';
|
|
3
|
+
interface RsiObservation {
|
|
4
|
+
readonly workspace: string;
|
|
5
|
+
readonly commit: string;
|
|
6
|
+
readonly turns: readonly RsiTurnEvidenceV1[];
|
|
7
|
+
}
|
|
8
|
+
interface RsiLifecycleState {
|
|
9
|
+
readonly version: 1;
|
|
10
|
+
readonly proposalDigest: string;
|
|
11
|
+
readonly comparisonDigest: string;
|
|
12
|
+
readonly candidateDigest: string;
|
|
13
|
+
readonly worktree: string;
|
|
14
|
+
readonly phase: LifecyclePhase;
|
|
15
|
+
readonly accepted?: {
|
|
16
|
+
readonly commit: string;
|
|
17
|
+
readonly at: number;
|
|
18
|
+
};
|
|
19
|
+
readonly rollback?: {
|
|
20
|
+
readonly parent: string;
|
|
21
|
+
readonly commit?: string;
|
|
22
|
+
readonly at?: number;
|
|
23
|
+
};
|
|
24
|
+
readonly observations: readonly RsiObservation[];
|
|
25
|
+
readonly rollbackObservation?: RsiObservation;
|
|
26
|
+
}
|
|
27
|
+
export interface RsiLifecycleReceipt extends RsiLifecycleState {
|
|
28
|
+
readonly digest: string;
|
|
29
|
+
}
|
|
30
|
+
type LifecycleAction = {
|
|
31
|
+
readonly action: 'apply';
|
|
32
|
+
readonly candidate: string;
|
|
33
|
+
readonly worktree: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly action: 'accept';
|
|
36
|
+
readonly commit: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly action: 'observe';
|
|
39
|
+
readonly input: string;
|
|
40
|
+
} | {
|
|
41
|
+
readonly action: 'rollback';
|
|
42
|
+
readonly worktree: string;
|
|
43
|
+
readonly commit?: string;
|
|
44
|
+
};
|
|
45
|
+
export declare function readRsiLifecycle(output: string, proposalDigest: string, comparisonDigest?: string): RsiLifecycleReceipt | undefined;
|
|
46
|
+
export declare function summarizeRsiObservations(state: RsiLifecycleReceipt, category: RsiCategory): {
|
|
47
|
+
turns: number;
|
|
48
|
+
recurrences: number;
|
|
49
|
+
toolCalls: number;
|
|
50
|
+
elapsedMs: number;
|
|
51
|
+
} | undefined;
|
|
52
|
+
export declare function advanceRsi(output: string, request: LifecycleAction): Promise<RsiLifecycleReceipt>;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|