@sema-agent/server 1.322.0 → 2.0.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/approval-hmac.d.ts +40 -0
- package/dist/approval-hmac.js +67 -0
- package/dist/approval.d.ts +31 -0
- package/dist/approval.js +72 -4
- package/dist/audit.d.ts +26 -0
- package/dist/audit.js +40 -1
- package/dist/auth-bridge.d.ts +10 -0
- package/dist/auth-bridge.js +47 -4
- package/dist/auth-keys.d.ts +19 -0
- package/dist/auth-keys.js +13 -0
- package/dist/bake-runner/main.d.ts +5 -0
- package/dist/bake-runner/main.js +43 -4
- package/dist/bake-runner/protocol.d.ts +57 -0
- package/dist/bake-runner/protocol.js +58 -3
- package/dist/bake-runner/runner.d.ts +54 -0
- package/dist/bake-runner/runner.js +87 -5
- package/dist/bench/l8/artifact.d.ts +63 -0
- package/dist/bench/l8/artifact.js +61 -2
- package/dist/bench/l8/escape.d.ts +36 -0
- package/dist/bench/l8/escape.js +25 -0
- package/dist/bench/l8/index.d.ts +14 -0
- package/dist/bench/l8/index.js +14 -0
- package/dist/bench/l8/probes.d.ts +74 -0
- package/dist/bench/l8/probes.js +60 -0
- package/dist/bench/l8/run-probes.d.ts +43 -0
- package/dist/bench/l8/run-probes.js +45 -2
- package/dist/bench/s1/arms.d.ts +126 -0
- package/dist/bench/s1/arms.js +188 -13
- package/dist/bench/s1/live-deps.d.ts +66 -0
- package/dist/bench/s1/live-deps.js +249 -11
- package/dist/bench/s1/oracle.d.ts +49 -0
- package/dist/bench/s1/oracle.js +36 -1
- package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
- package/dist/bench/s1/repair-oracle-adapter.js +30 -0
- package/dist/bench/s1/reviewer.d.ts +38 -0
- package/dist/bench/s1/reviewer.js +34 -0
- package/dist/bench/s1/row.d.ts +77 -0
- package/dist/bench/s1/row.js +62 -0
- package/dist/bench/s1/run-firm.d.ts +47 -0
- package/dist/bench/s1/run-firm.js +70 -4
- package/dist/bench/s1/runner-ctx.d.ts +71 -0
- package/dist/bench/s1/runner-ctx.js +36 -0
- package/dist/bench/s1/tasks.d.ts +108 -0
- package/dist/bench/s1/tasks.js +115 -0
- package/dist/boot-reclaim.d.ts +19 -0
- package/dist/boot-reclaim.js +20 -0
- package/dist/brain.d.ts +25 -0
- package/dist/brain.js +61 -1
- package/dist/budget.d.ts +66 -0
- package/dist/budget.js +128 -4
- package/dist/capabilities/builtin-tools.d.ts +3 -0
- package/dist/capabilities/builtin-tools.js +3 -0
- package/dist/capabilities/center-plugins.d.ts +17 -1
- package/dist/capabilities/center-plugins.js +45 -4
- package/dist/capabilities/center-prompts.d.ts +46 -0
- package/dist/capabilities/center-prompts.js +57 -3
- package/dist/capabilities/code-review-council.d.ts +28 -0
- package/dist/capabilities/code-review-council.js +40 -7
- package/dist/capabilities/collab-wire.d.ts +2 -0
- package/dist/capabilities/collab-workflows.d.ts +7 -0
- package/dist/capabilities/collab-workflows.js +44 -1
- package/dist/capabilities/oa-tools.d.ts +6 -0
- package/dist/capabilities/oa-tools.js +10 -0
- package/dist/capabilities/prompt.d.ts +14 -0
- package/dist/capabilities/prompt.js +14 -0
- package/dist/capabilities/prompts/code-review.d.ts +14 -0
- package/dist/capabilities/prompts/code-review.js +14 -0
- package/dist/capabilities/prompts/identity.d.ts +6 -0
- package/dist/capabilities/prompts/identity.js +6 -0
- package/dist/capabilities/prompts/team.d.ts +4 -0
- package/dist/capabilities/prompts/team.js +4 -0
- package/dist/capabilities/repo-tools.d.ts +11 -0
- package/dist/capabilities/repo-tools.js +8 -0
- package/dist/capabilities/sandbox-file-send.d.ts +95 -0
- package/dist/capabilities/sandbox-file-send.js +91 -3
- package/dist/capabilities/scenarios.d.ts +130 -0
- package/dist/capabilities/scenarios.js +180 -7
- package/dist/capabilities/select-environment-tool.d.ts +7 -0
- package/dist/capabilities/select-environment-tool.js +30 -0
- package/dist/capabilities/send-user-file-tool.d.ts +33 -0
- package/dist/capabilities/send-user-file-tool.js +65 -1
- package/dist/capabilities/skills.d.ts +29 -0
- package/dist/capabilities/skills.js +13 -2
- package/dist/capabilities/team.d.ts +22 -0
- package/dist/capabilities/team.js +22 -2
- package/dist/capabilities/tool-defer.d.ts +26 -0
- package/dist/capabilities/tool-defer.js +3 -0
- package/dist/config-center/apply-effective.d.ts +65 -0
- package/dist/config-center/apply-effective.js +204 -12
- package/dist/config-center/http-client.d.ts +34 -0
- package/dist/config-center/http-client.js +68 -0
- package/dist/config-center/restart-signal.d.ts +22 -0
- package/dist/config-center/restart-signal.js +39 -0
- package/dist/config-center/skills-mcp.d.ts +20 -1
- package/dist/config-center/skills-mcp.js +42 -7
- package/dist/config-center/types.d.ts +92 -1
- package/dist/config-lkg.d.ts +12 -0
- package/dist/config-lkg.js +41 -0
- package/dist/config-provider.d.ts +78 -0
- package/dist/config-provider.js +165 -2
- package/dist/config-types.d.ts +546 -0
- package/dist/config.d.ts +64 -0
- package/dist/config.js +455 -60
- package/dist/degenerate-instrument.d.ts +38 -0
- package/dist/degenerate-instrument.js +55 -3
- package/dist/elicitation.d.ts +39 -0
- package/dist/elicitation.js +87 -3
- package/dist/env-facts.d.ts +61 -0
- package/dist/env-facts.js +73 -7
- package/dist/fleet/fleet-bus.d.ts +185 -0
- package/dist/fleet/fleet-bus.js +333 -27
- package/dist/fleet/subagent-tail-bus.d.ts +11 -0
- package/dist/fleet/subagent-tail-bus.js +33 -2
- package/dist/fleet-client.d.ts +38 -0
- package/dist/fleet-client.js +44 -9
- package/dist/fleet-lease.d.ts +46 -0
- package/dist/fleet-lease.js +73 -5
- package/dist/hooks/branch-transcript.d.ts +8 -0
- package/dist/hooks/branch-transcript.js +33 -0
- package/dist/hooks/cc-stop-prompt.d.ts +42 -0
- package/dist/hooks/cc-stop-prompt.js +43 -1
- package/dist/hooks/hook-llm.d.ts +15 -0
- package/dist/hooks/hook-llm.js +47 -0
- package/dist/hooks/hook-runner.d.ts +89 -0
- package/dist/hooks/hook-runner.js +327 -18
- package/dist/http/idempotency.d.ts +31 -0
- package/dist/http/idempotency.js +34 -0
- package/dist/http/principal-gate.d.ts +17 -0
- package/dist/http/principal-gate.js +35 -3
- package/dist/http/route-ctx.d.ts +36 -0
- package/dist/http/routes/approvals-assistant.d.ts +25 -0
- package/dist/http/routes/approvals-assistant.js +253 -23
- package/dist/http/routes/attachments.js +22 -4
- package/dist/http/routes/capabilities.d.ts +7 -0
- package/dist/http/routes/capabilities.js +202 -1
- package/dist/http/routes/fleet.d.ts +6 -0
- package/dist/http/routes/fleet.js +94 -5
- package/dist/http/routes/images.d.ts +17 -0
- package/dist/http/routes/images.js +222 -14
- package/dist/http/routes/leader.d.ts +7 -0
- package/dist/http/routes/leader.js +10 -0
- package/dist/http/routes/memory-policy.d.ts +6 -0
- package/dist/http/routes/memory-policy.js +38 -6
- package/dist/http/routes/notify-wake.d.ts +10 -0
- package/dist/http/routes/notify-wake.js +19 -3
- package/dist/http/routes/observability.d.ts +6 -0
- package/dist/http/routes/observability.js +19 -2
- package/dist/http/routes/runs.d.ts +15 -0
- package/dist/http/routes/runs.js +464 -41
- package/dist/http/routes/session-sync.d.ts +15 -0
- package/dist/http/routes/session-sync.js +229 -19
- package/dist/http/routes/sessions-list.d.ts +6 -0
- package/dist/http/routes/sessions-list.js +35 -4
- package/dist/http/routes/sessions.d.ts +14 -0
- package/dist/http/routes/sessions.js +176 -31
- package/dist/http/routes/side-query.d.ts +8 -0
- package/dist/http/routes/side-query.js +26 -1
- package/dist/http/routes/tasks.d.ts +18 -0
- package/dist/http/routes/tasks.js +501 -38
- package/dist/http/routes/trace-usage.d.ts +10 -0
- package/dist/http/routes/trace-usage.js +66 -14
- package/dist/http/routes/workflows.d.ts +12 -0
- package/dist/http/routes/workflows.js +180 -19
- package/dist/http/run-meta.d.ts +11 -0
- package/dist/http/run-meta.js +6 -0
- package/dist/http/send.d.ts +19 -0
- package/dist/http/send.js +11 -0
- package/dist/http/server.d.ts +255 -0
- package/dist/http/server.js +921 -75
- package/dist/http/sse-log.d.ts +15 -0
- package/dist/http/sse-log.js +16 -0
- package/dist/http/tar.d.ts +9 -0
- package/dist/http/tar.js +21 -5
- package/dist/http/wire-gate.d.ts +9 -0
- package/dist/http/wire-gate.js +9 -0
- package/dist/http/wire-types.d.ts +187 -0
- package/dist/http/workspace-content.d.ts +8 -0
- package/dist/http/workspace-content.js +10 -0
- package/dist/images/bake-validate.d.ts +63 -0
- package/dist/images/bake-validate.js +71 -1
- package/dist/images/manifest.d.ts +19 -0
- package/dist/images/manifest.js +6 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.js +10 -5
- package/dist/key-resolver.d.ts +23 -0
- package/dist/key-resolver.js +27 -2
- package/dist/leader/diffout.d.ts +23 -0
- package/dist/leader/diffout.js +8 -1
- package/dist/leader/diffup.d.ts +32 -0
- package/dist/leader/diffup.js +43 -0
- package/dist/leader/endpoint.d.ts +20 -0
- package/dist/leader/endpoint.js +25 -2
- package/dist/leader/fanout.d.ts +60 -0
- package/dist/leader/fanout.js +29 -3
- package/dist/leader/grader-env-factory.d.ts +74 -0
- package/dist/leader/grader-env-factory.js +62 -3
- package/dist/leader/leader.d.ts +97 -0
- package/dist/leader/leader.js +151 -4
- package/dist/leader/merge.d.ts +94 -0
- package/dist/leader/merge.js +112 -9
- package/dist/leader/planner.d.ts +52 -0
- package/dist/leader/planner.js +47 -3
- package/dist/leader/repair-oracle.d.ts +61 -0
- package/dist/leader/repair-oracle.js +59 -1
- package/dist/leader/repair-wire.d.ts +78 -0
- package/dist/leader/repair-wire.js +79 -2
- package/dist/leader/wire.d.ts +79 -0
- package/dist/leader/wire.js +255 -8
- package/dist/lsp/e2b-bridge.d.ts +16 -0
- package/dist/lsp/e2b-bridge.js +32 -4
- package/dist/lsp/e2b-manager.d.ts +10 -0
- package/dist/lsp/e2b-manager.js +18 -2
- package/dist/lsp/lsp-frames.d.ts +12 -0
- package/dist/lsp/lsp-frames.js +12 -0
- package/dist/lsp/manager.d.ts +12 -0
- package/dist/lsp/manager.js +35 -2
- package/dist/lsp/types.d.ts +10 -0
- package/dist/lsp/ws-transport.d.ts +12 -0
- package/dist/lsp/ws-transport.js +53 -5
- package/dist/lsp-evict.d.ts +14 -0
- package/dist/lsp-evict.js +15 -1
- package/dist/main.js +2132 -96
- package/dist/memory-export.d.ts +1 -0
- package/dist/memory-export.js +4 -0
- package/dist/memory-scope.d.ts +49 -0
- package/dist/memory-scope.js +87 -4
- package/dist/memory-sync-client.d.ts +24 -0
- package/dist/memory-sync-client.js +41 -2
- package/dist/memory-sync.d.ts +23 -0
- package/dist/memory-sync.js +70 -1
- package/dist/model-select.d.ts +39 -0
- package/dist/model-select.js +42 -1
- package/dist/observability/cost-quota.d.ts +20 -0
- package/dist/observability/cost-quota.js +4 -0
- package/dist/observability/cost-taxonomy.d.ts +45 -0
- package/dist/observability/cost-taxonomy.js +34 -0
- package/dist/observability/logger.d.ts +1 -0
- package/dist/observability/logger.js +6 -0
- package/dist/observability/metrics.d.ts +13 -0
- package/dist/observability/metrics.js +63 -0
- package/dist/observability/otel-exporter.d.ts +9 -0
- package/dist/observability/otel-exporter.js +11 -3
- package/dist/observability/principal-context.d.ts +9 -0
- package/dist/observability/principal-context.js +9 -0
- package/dist/observability/prompt-manifest.d.ts +37 -0
- package/dist/observability/prompt-manifest.js +35 -1
- package/dist/observability/rate-limit.d.ts +10 -0
- package/dist/observability/rate-limit.js +1 -0
- package/dist/observability/tool-trace.d.ts +24 -0
- package/dist/observability/tool-trace.js +41 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
- package/dist/orchestration/hardened-vm-runner.js +119 -4
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
- package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
- package/dist/orchestration/hardened-vm-worker.js +27 -0
- package/dist/orchestration/subagent-steer.d.ts +44 -0
- package/dist/orchestration/subagent-steer.js +45 -1
- package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
- package/dist/orchestration/workflow-agent-steer.js +80 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
- package/dist/orchestration/workflow-completion-inbox.js +283 -32
- package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
- package/dist/orchestration/workflow-notify-journal.js +187 -13
- package/dist/parked-decide.d.ts +61 -0
- package/dist/parked-decide.js +58 -1
- package/dist/per-task-image.d.ts +54 -0
- package/dist/per-task-image.js +41 -0
- package/dist/plan-cache-probe.d.ts +35 -0
- package/dist/plan-cache-probe.js +18 -3
- package/dist/plugins/approval-exemption-store.d.ts +7 -0
- package/dist/plugins/approval-exemption-store.js +28 -2
- package/dist/plugins/approval-store-sql.d.ts +64 -0
- package/dist/plugins/approval-store-sql.js +32 -0
- package/dist/plugins/background-agent-store-sql.d.ts +55 -0
- package/dist/plugins/background-agent-store-sql.js +91 -4
- package/dist/plugins/background-shell-support.d.ts +98 -0
- package/dist/plugins/background-shell-support.js +117 -13
- package/dist/plugins/blob-backend.d.ts +104 -0
- package/dist/plugins/blob-backend.js +163 -6
- package/dist/plugins/breaker-state-sql.d.ts +65 -1
- package/dist/plugins/breaker-state-sql.js +46 -8
- package/dist/plugins/caching-session-store.d.ts +42 -0
- package/dist/plugins/caching-session-store.js +63 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
- package/dist/plugins/checkpoint-store-sql.js +239 -11
- package/dist/plugins/file-outcome-sink.d.ts +4 -0
- package/dist/plugins/file-outcome-sink.js +9 -0
- package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
- package/dist/plugins/file-resume-anchor-store.js +43 -4
- package/dist/plugins/file-run-store.d.ts +90 -0
- package/dist/plugins/file-run-store.js +145 -13
- package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
- package/dist/plugins/file-snapshot-store-sql.js +178 -10
- package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
- package/dist/plugins/file-workflow-journal-store.js +10 -0
- package/dist/plugins/fork-routing-session-store.d.ts +47 -0
- package/dist/plugins/fork-routing-session-store.js +51 -3
- package/dist/plugins/host-platform.d.ts +69 -0
- package/dist/plugins/host-platform.js +81 -2
- package/dist/plugins/image-bake-store-sql.d.ts +136 -1
- package/dist/plugins/image-bake-store-sql.js +241 -7
- package/dist/plugins/image-index-sql.d.ts +46 -0
- package/dist/plugins/image-index-sql.js +113 -4
- package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
- package/dist/plugins/k8s-bg-scripts.js +88 -4
- package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
- package/dist/plugins/k8s-exec-protocol.js +41 -0
- package/dist/plugins/local-checkpoint-store.d.ts +40 -0
- package/dist/plugins/local-checkpoint-store.js +86 -7
- package/dist/plugins/local-session-store.d.ts +157 -0
- package/dist/plugins/local-session-store.js +289 -34
- package/dist/plugins/local-task-attachment-store.js +14 -2
- package/dist/plugins/mailbox-store-sql.d.ts +38 -0
- package/dist/plugins/mailbox-store-sql.js +39 -6
- package/dist/plugins/memory-engine-pg.d.ts +30 -0
- package/dist/plugins/memory-engine-pg.js +122 -4
- package/dist/plugins/memory-engine-tidb.d.ts +26 -0
- package/dist/plugins/memory-engine-tidb.js +115 -5
- package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
- package/dist/plugins/memory-engine-vector-util.js +5 -0
- package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
- package/dist/plugins/memory-resume-anchor-store.js +17 -0
- package/dist/plugins/memory-run-store.d.ts +63 -0
- package/dist/plugins/memory-run-store.js +73 -8
- package/dist/plugins/memory-session-policy-store.d.ts +17 -0
- package/dist/plugins/memory-session-policy-store.js +17 -0
- package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
- package/dist/plugins/memory-sync-store-pg.js +45 -2
- package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
- package/dist/plugins/memory-sync-store-tidb.js +31 -1
- package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
- package/dist/plugins/outcome-ledger-sql.js +97 -3
- package/dist/plugins/pg-approval-store.d.ts +7 -0
- package/dist/plugins/pg-approval-store.js +7 -0
- package/dist/plugins/pg-breaker-state.d.ts +6 -0
- package/dist/plugins/pg-breaker-state.js +6 -0
- package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
- package/dist/plugins/pg-checkpoint-store.js +8 -0
- package/dist/plugins/pg-cost-quota.d.ts +17 -0
- package/dist/plugins/pg-cost-quota.js +6 -0
- package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/pg-file-snapshot-store.js +6 -0
- package/dist/plugins/pg-image-bake.d.ts +9 -0
- package/dist/plugins/pg-image-bake.js +9 -0
- package/dist/plugins/pg-image-index.d.ts +9 -0
- package/dist/plugins/pg-image-index.js +9 -0
- package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
- package/dist/plugins/pg-outcome-ledger.js +9 -0
- package/dist/plugins/pg-pool.d.ts +50 -0
- package/dist/plugins/pg-pool.js +78 -0
- package/dist/plugins/pg-query.d.ts +11 -0
- package/dist/plugins/pg-rate-limiter.d.ts +23 -0
- package/dist/plugins/pg-rate-limiter.js +12 -2
- package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/pg-resume-anchor-store.js +5 -0
- package/dist/plugins/pg-run-store.d.ts +7 -0
- package/dist/plugins/pg-run-store.js +7 -0
- package/dist/plugins/pg-safe-json.d.ts +13 -0
- package/dist/plugins/pg-safe-json.js +40 -4
- package/dist/plugins/pg-session-policy-store.d.ts +5 -0
- package/dist/plugins/pg-session-policy-store.js +5 -0
- package/dist/plugins/pg-session-storage.d.ts +72 -0
- package/dist/plugins/pg-session-storage.js +152 -20
- package/dist/plugins/pg-session-store.d.ts +10 -0
- package/dist/plugins/pg-session-store.js +10 -0
- package/dist/plugins/pg-tool-result-store.d.ts +7 -0
- package/dist/plugins/pg-tool-result-store.js +7 -0
- package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-journal-store.js +7 -0
- package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
- package/dist/plugins/pg-workflow-run-store.js +7 -0
- package/dist/plugins/posix-shell-fs.d.ts +3 -0
- package/dist/plugins/posix-shell-fs.js +31 -1
- package/dist/plugins/remote-env-adb.d.ts +25 -0
- package/dist/plugins/remote-env-adb.js +95 -12
- package/dist/plugins/remote-env-e2b.d.ts +146 -0
- package/dist/plugins/remote-env-e2b.js +371 -40
- package/dist/plugins/remote-env-file-error.d.ts +34 -0
- package/dist/plugins/remote-env-file-error.js +37 -0
- package/dist/plugins/remote-env-host.d.ts +151 -0
- package/dist/plugins/remote-env-host.js +468 -70
- package/dist/plugins/remote-env-k8s.d.ts +135 -0
- package/dist/plugins/remote-env-k8s.js +318 -32
- package/dist/plugins/remote-env-local-docker.d.ts +65 -0
- package/dist/plugins/remote-env-local-docker.js +149 -24
- package/dist/plugins/remote-env-ssh.d.ts +35 -0
- package/dist/plugins/remote-env-ssh.js +117 -20
- package/dist/plugins/remote-scratchpad.d.ts +38 -0
- package/dist/plugins/remote-scratchpad.js +32 -2
- package/dist/plugins/remote-shell.d.ts +22 -0
- package/dist/plugins/remote-shell.js +27 -1
- package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
- package/dist/plugins/resume-anchor-store-sql.js +11 -0
- package/dist/plugins/roster-store-sql.d.ts +27 -0
- package/dist/plugins/roster-store-sql.js +54 -0
- package/dist/plugins/run-store-sql.d.ts +194 -0
- package/dist/plugins/run-store-sql.js +210 -9
- package/dist/plugins/s3-presign.d.ts +20 -0
- package/dist/plugins/s3-presign.js +49 -2
- package/dist/plugins/scheduler-support.d.ts +12 -0
- package/dist/plugins/scheduler-support.js +75 -3
- package/dist/plugins/send-file-ledger.d.ts +15 -0
- package/dist/plugins/send-file-ledger.js +53 -4
- package/dist/plugins/send-user-file.d.ts +77 -0
- package/dist/plugins/send-user-file.js +92 -4
- package/dist/plugins/session-policy-store-sql.d.ts +15 -0
- package/dist/plugins/session-policy-store-sql.js +75 -3
- package/dist/plugins/session-store.d.ts +45 -0
- package/dist/plugins/session-store.js +51 -0
- package/dist/plugins/sql-driver.d.ts +77 -0
- package/dist/plugins/sql-driver.js +4 -0
- package/dist/plugins/sql-escape.d.ts +8 -0
- package/dist/plugins/sql-escape.js +8 -0
- package/dist/plugins/sql-row-helpers.d.ts +25 -0
- package/dist/plugins/sql-row-helpers.js +25 -0
- package/dist/plugins/store-backend.d.ts +103 -0
- package/dist/plugins/store-backend.js +120 -27
- package/dist/plugins/store-contracts.d.ts +62 -0
- package/dist/plugins/store-contracts.js +3 -0
- package/dist/plugins/task-attachment-store.d.ts +60 -0
- package/dist/plugins/task-attachment-store.js +49 -3
- package/dist/plugins/task-list-store-sql.d.ts +25 -0
- package/dist/plugins/task-list-store-sql.js +21 -0
- package/dist/plugins/tidb-approval-store.d.ts +6 -0
- package/dist/plugins/tidb-approval-store.js +6 -0
- package/dist/plugins/tidb-breaker-state.d.ts +5 -0
- package/dist/plugins/tidb-breaker-state.js +5 -0
- package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
- package/dist/plugins/tidb-checkpoint-store.js +7 -0
- package/dist/plugins/tidb-cost-quota.d.ts +6 -0
- package/dist/plugins/tidb-cost-quota.js +1 -0
- package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
- package/dist/plugins/tidb-file-snapshot-store.js +6 -0
- package/dist/plugins/tidb-image-bake.d.ts +8 -0
- package/dist/plugins/tidb-image-bake.js +8 -0
- package/dist/plugins/tidb-image-index.d.ts +8 -0
- package/dist/plugins/tidb-image-index.js +8 -0
- package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
- package/dist/plugins/tidb-outcome-ledger.js +10 -0
- package/dist/plugins/tidb-pool.d.ts +56 -0
- package/dist/plugins/tidb-pool.js +181 -1
- package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
- package/dist/plugins/tidb-rate-limiter.js +5 -2
- package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
- package/dist/plugins/tidb-resume-anchor-store.js +5 -0
- package/dist/plugins/tidb-run-store.d.ts +7 -0
- package/dist/plugins/tidb-run-store.js +7 -0
- package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
- package/dist/plugins/tidb-session-policy-store.js +5 -0
- package/dist/plugins/tidb-session-storage.d.ts +43 -0
- package/dist/plugins/tidb-session-storage.js +62 -3
- package/dist/plugins/tidb-session-store.d.ts +142 -0
- package/dist/plugins/tidb-session-store.js +264 -16
- package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
- package/dist/plugins/tidb-tool-result-store.js +7 -0
- package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
- package/dist/plugins/tidb-workflow-journal-store.js +7 -0
- package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
- package/dist/plugins/tidb-workflow-run-store.js +8 -0
- package/dist/plugins/tool-result-store-sql.d.ts +58 -0
- package/dist/plugins/tool-result-store-sql.js +38 -2
- package/dist/plugins/web-search.d.ts +35 -0
- package/dist/plugins/web-search.js +45 -9
- package/dist/plugins/workflow-journal-limits.d.ts +10 -0
- package/dist/plugins/workflow-journal-limits.js +10 -0
- package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
- package/dist/plugins/workflow-journal-store-sql.js +59 -3
- package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
- package/dist/plugins/workflow-run-store-sql.js +84 -6
- package/dist/plugins/worktree-isolation.d.ts +45 -0
- package/dist/plugins/worktree-isolation.js +105 -6
- package/dist/plugins/write-behind-counter.d.ts +56 -1
- package/dist/plugins/write-behind-counter.js +53 -14
- package/dist/principal-jwt.d.ts +24 -0
- package/dist/principal-jwt.js +60 -5
- package/dist/project-memory.d.ts +22 -0
- package/dist/project-memory.js +144 -15
- package/dist/prompts-domain-validate.d.ts +28 -0
- package/dist/prompts-domain-validate.js +42 -1
- package/dist/question.d.ts +33 -0
- package/dist/question.js +69 -2
- package/dist/resource-suspend.d.ts +21 -0
- package/dist/resource-suspend.js +16 -0
- package/dist/router/route-orchestration.d.ts +78 -0
- package/dist/router/route-orchestration.js +77 -0
- package/dist/run-local.d.ts +32 -0
- package/dist/run-local.js +172 -8
- package/dist/runs.d.ts +189 -4
- package/dist/runs.js +465 -24
- package/dist/runtime-caps-resolver.d.ts +106 -0
- package/dist/runtime-caps-resolver.js +89 -4
- package/dist/runtime-governance.d.ts +84 -0
- package/dist/runtime-governance.js +127 -1
- package/dist/sandbox-pkg-source.d.ts +23 -0
- package/dist/sandbox-pkg-source.js +37 -0
- package/dist/sealed-key.d.ts +54 -0
- package/dist/sealed-key.js +68 -3
- package/dist/security.d.ts +108 -0
- package/dist/security.js +145 -6
- package/dist/sema-registry.d.ts +21 -0
- package/dist/sema-registry.js +21 -0
- package/dist/session-leaf-bus.d.ts +31 -0
- package/dist/session-leaf-bus.js +32 -0
- package/dist/session-sync-content.d.ts +46 -0
- package/dist/session-sync-content.js +47 -1
- package/dist/session-sync-kernel.d.ts +89 -0
- package/dist/session-sync-kernel.js +48 -3
- package/dist/session-sync.d.ts +125 -0
- package/dist/session-sync.js +181 -8
- package/dist/session-titler.d.ts +26 -0
- package/dist/session-titler.js +41 -7
- package/dist/session-watch.d.ts +53 -1
- package/dist/session-watch.js +73 -9
- package/dist/sighup-idle.d.ts +30 -0
- package/dist/sighup-idle.js +12 -1
- package/dist/spec-fields.d.ts +91 -3
- package/dist/spec-fields.js +116 -4
- package/dist/task-cwd.d.ts +50 -0
- package/dist/task-cwd.js +68 -1
- package/dist/task-mcp.d.ts +47 -0
- package/dist/task-mcp.js +29 -0
- package/dist/task-settings.d.ts +175 -0
- package/dist/task-settings.js +226 -11
- package/dist/task-workflow.d.ts +67 -0
- package/dist/task-workflow.js +75 -8
- package/dist/tool-approval.d.ts +91 -0
- package/dist/tool-approval.js +215 -0
- package/dist/trace/artifacts.d.ts +9 -0
- package/dist/trace/artifacts.js +30 -5
- package/dist/trace/core-keyset-guard.d.ts +18 -0
- package/dist/trace/ledger-sink.d.ts +43 -0
- package/dist/trace/ledger-sink.js +64 -5
- package/dist/trace/project.d.ts +133 -0
- package/dist/trace/project.js +189 -2
- package/dist/trace/redact.d.ts +19 -0
- package/dist/trace/redact.js +66 -9
- package/dist/usage-analytics.d.ts +26 -0
- package/dist/usage-analytics.js +26 -3
- package/package.json +1 -1
|
@@ -1,4 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PROFILE-injected `RepairOracle` closure for the leader's single-agent self-repair loop
|
|
3
|
+
* (`runRepairLoop`, core design/78 / D1). See `docs/LEADER-REPAIRLOOP-INTEGRATION.md` (§3.1 + the authoritative
|
|
4
|
+
* §10 corrected layer). The closure GRADES a worker's candidate in an ISOLATED grader env (the reused
|
|
5
|
+
* integration sandbox, distinct from the worker env) and maps the result to a core `OracleResult`. core only
|
|
6
|
+
* fixes the `OracleResult` shape + the read-only/identity contract; the composition lives HERE so the core type
|
|
7
|
+
* never grows a discriminated union.
|
|
8
|
+
*
|
|
9
|
+
* Hardened by the adversarial round (§10):
|
|
10
|
+
* - §10.1 HERMETIC grade: the grader tree is reset to a clean base (`git reset --hard <integBase> && git clean
|
|
11
|
+
* -fdx`) BEFORE applying the worker's LATEST full `base..HEAD` diff each call — so a 2nd/3rd attempt never
|
|
12
|
+
* applies cumulatively onto an already-applied tree (the BROKEN finding). The diff is recomputed fresh every
|
|
13
|
+
* call (never a stale cached diff — verify.ts:328 BUG5).
|
|
14
|
+
* - flaky: the gate is re-isolated K times on a green-looking verdict; a disagreement is reported `flaky:true`
|
|
15
|
+
* and core's `terminalForTier` provably refuses to project it to a passing terminal.
|
|
16
|
+
* - §10.9 DE-CORRELATION: the L3 judge can only contribute a CLEARING tier when the verifier model is PROVABLY
|
|
17
|
+
* distinct from the generator — and the closure CANNOT resolve roles→models itself (that happens inside
|
|
18
|
+
* `Runner.runTask` after the closure returns), so the WIRE resolves both ids and passes them in; the closure
|
|
19
|
+
* downgrades to `l3_judge_advisory` when they are equal. v1 ships L3 OFF (`cfg.l3` unset) → L2 `trusted_hidden`
|
|
20
|
+
* is the sole clearer and `terminalForTier` caps every PASS at `candidate_only`. Wiring the actual
|
|
21
|
+
* `verifyCompleted` invocation is a future enable: it needs the worker's `TaskResult` threaded to the oracle
|
|
22
|
+
* (core passes only the report `evidence` today), so it is deliberately NOT invoked here.
|
|
23
|
+
*
|
|
24
|
+
* The grader topology (graderEnv = the reused integration sandbox, oracle seeded ONLY there, worker env distinct)
|
|
25
|
+
* means the worker can never read the oracle; for SAFE-tier `candidate_only` the bare `graderEnv !== workerEnv`
|
|
26
|
+
* identity check is sufficient, so the caller OMITS `immutableOraclePaths` (the structural bash write-probe is
|
|
27
|
+
* vacuous across distinct sandboxes and matters only for the mandate-OFF auto-accept path — §10.2).
|
|
28
|
+
*/
|
|
1
29
|
import { type ExecStep, type OracleTier, type RepairOracle } from "@sema-agent/core";
|
|
30
|
+
/** A worker's latest diff, pulled fresh from ITS env (the same `PullDiffResult` shape as `diffout.ts`). */
|
|
2
31
|
export type WorkerDiff = {
|
|
3
32
|
ok: true;
|
|
4
33
|
patch: string;
|
|
@@ -7,22 +36,49 @@ export type WorkerDiff = {
|
|
|
7
36
|
error: string;
|
|
8
37
|
};
|
|
9
38
|
export interface RepairOracleCfg {
|
|
39
|
+
/** Pull the worker's LATEST full `base..HEAD` diff from its own env (recomputed every grade — §10.1). */
|
|
10
40
|
pullWorkerDiff: () => Promise<WorkerDiff>;
|
|
41
|
+
/** Write a file into the GRADER env (the wire binds this to the integration sandbox's `writeFile`). */
|
|
11
42
|
graderWriteFile: (path: string, content: string) => Promise<void>;
|
|
43
|
+
/** Repo dir inside the grader (e.g. `/repo`). */
|
|
12
44
|
graderRepoDir: string;
|
|
45
|
+
/** The grader's CLEAN base rev — `git rev-parse HEAD` taken right after seed + oracle-inject (`merge.ts:137`
|
|
46
|
+
* pattern). The §10.1 hermetic reset target; the grade always runs base→latest, never cumulative. */
|
|
13
47
|
integBase: string;
|
|
48
|
+
/** TRUSTED, spec-derived oracle steps (the hidden-oracle `testCmd` [+ `measureCmd`]) run in the grader. MUST
|
|
49
|
+
* NOT be worker-authored (the security contract of `runExecGate` — exec-gate.ts header). */
|
|
14
50
|
oracleSteps: ExecStep[];
|
|
51
|
+
/** The tier to assign on a PASS (control-plane data, never agent-visible): `trusted_hidden` iff the steps run
|
|
52
|
+
* an oracleFiles-backed hidden held-out oracle; `property_harness_weak` for a compile-only gate; `none` if
|
|
53
|
+
* there is no usable oracle. */
|
|
15
54
|
passTier: OracleTier;
|
|
55
|
+
/** K re-isolations to settle a flaky verdict (`LEADER_ORACLE_FLAKY_K`, default 2). */
|
|
16
56
|
flakyK?: number;
|
|
57
|
+
/** Optional L3 de-correlation gate (§10.9). When the leader runs a distinct verifier model, the wire resolves
|
|
58
|
+
* both ids and passes them; a self-certifying pair (`verifierModelId === generatorModelId`) downgrades a PASS
|
|
59
|
+
* to `l3_judge_advisory` (advisory never clears). Unset in v1 (L3 off → the L2 tier stands). */
|
|
17
60
|
l3?: {
|
|
18
61
|
generatorModelId: string;
|
|
19
62
|
verifierModelId: string;
|
|
20
63
|
};
|
|
64
|
+
/** fork1.2 — paths the candidate patch must NOT touch (the seeded hidden-oracle / test paths).
|
|
65
|
+
* The §10.2 factory lane OMITs the engine's path-level probe, so a patch that EDITS the grader's oracle could
|
|
66
|
+
* tamper with the grade and get rubber-stamped as `candidate_only`. A patch touching one of these is REFUSED
|
|
67
|
+
* as `needs_human_oracle` (surfaced for a human, never a silent candidate). Matched by exact path or subtree. */
|
|
21
68
|
oraclePaths?: string[];
|
|
69
|
+
/** 🔴 council 2026-06-17 — the seeded hidden-oracle files (path + content). The hermetic `git clean -fdx`
|
|
70
|
+
* DELETES them (they are untracked/ignored, not committed at `integBase`), so they MUST be RE-INJECTED after
|
|
71
|
+
* the worker patch is applied — both to restore the oracle the `clean` wiped AND to overwrite any file the
|
|
72
|
+
* patch placed at an oracle path (defence-in-depth with `oraclePaths`). Without this the gate runs against NO
|
|
73
|
+
* oracle (or a worker-substituted one) and `trusted_hidden` is a false label. Empty when grading is a pure
|
|
74
|
+
* inline `testCmd` with no seeded files (then there is nothing for `clean` to wipe). */
|
|
22
75
|
oracleFiles?: Array<{
|
|
23
76
|
path: string;
|
|
24
77
|
content: string;
|
|
25
78
|
}>;
|
|
79
|
+
/** fork2.2 — report the EXACT bytes that were graded (the diff + its hash) so the caller binds
|
|
80
|
+
* the SURFACED candidate to the graded artifact (a human reviews the bytes that produced the verdict, not a
|
|
81
|
+
* re-pulled diff that may differ). Isomorphic to core's boundInputHash: "grade/review the thing you ship". */
|
|
26
82
|
onGraded?: (info: {
|
|
27
83
|
diff: string;
|
|
28
84
|
hash: string;
|
|
@@ -30,5 +86,10 @@ export interface RepairOracleCfg {
|
|
|
30
86
|
}) => void;
|
|
31
87
|
log?: (event: string, x?: Record<string, unknown>) => void;
|
|
32
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Build the `RepairOracle` closure. The returned `(graderEnv, evidence) => OracleResult` is what the leader
|
|
91
|
+
* passes as `RepairLoopConfig.oracle`. `evidence` (the worker's report text) is intentionally unused — the
|
|
92
|
+
* closure recomputes the candidate diff from the worker env each call (§10.1).
|
|
93
|
+
*/
|
|
33
94
|
export declare function mkRepairOracle(cfg: RepairOracleCfg): RepairOracle;
|
|
34
95
|
//# sourceMappingURL=repair-oracle.d.ts.map
|
|
@@ -1,7 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PROFILE-injected `RepairOracle` closure for the leader's single-agent self-repair loop
|
|
3
|
+
* (`runRepairLoop`, core design/78 / D1). See `docs/LEADER-REPAIRLOOP-INTEGRATION.md` (§3.1 + the authoritative
|
|
4
|
+
* §10 corrected layer). The closure GRADES a worker's candidate in an ISOLATED grader env (the reused
|
|
5
|
+
* integration sandbox, distinct from the worker env) and maps the result to a core `OracleResult`. core only
|
|
6
|
+
* fixes the `OracleResult` shape + the read-only/identity contract; the composition lives HERE so the core type
|
|
7
|
+
* never grows a discriminated union.
|
|
8
|
+
*
|
|
9
|
+
* Hardened by the adversarial round (§10):
|
|
10
|
+
* - §10.1 HERMETIC grade: the grader tree is reset to a clean base (`git reset --hard <integBase> && git clean
|
|
11
|
+
* -fdx`) BEFORE applying the worker's LATEST full `base..HEAD` diff each call — so a 2nd/3rd attempt never
|
|
12
|
+
* applies cumulatively onto an already-applied tree (the BROKEN finding). The diff is recomputed fresh every
|
|
13
|
+
* call (never a stale cached diff — verify.ts:328 BUG5).
|
|
14
|
+
* - flaky: the gate is re-isolated K times on a green-looking verdict; a disagreement is reported `flaky:true`
|
|
15
|
+
* and core's `terminalForTier` provably refuses to project it to a passing terminal.
|
|
16
|
+
* - §10.9 DE-CORRELATION: the L3 judge can only contribute a CLEARING tier when the verifier model is PROVABLY
|
|
17
|
+
* distinct from the generator — and the closure CANNOT resolve roles→models itself (that happens inside
|
|
18
|
+
* `Runner.runTask` after the closure returns), so the WIRE resolves both ids and passes them in; the closure
|
|
19
|
+
* downgrades to `l3_judge_advisory` when they are equal. v1 ships L3 OFF (`cfg.l3` unset) → L2 `trusted_hidden`
|
|
20
|
+
* is the sole clearer and `terminalForTier` caps every PASS at `candidate_only`. Wiring the actual
|
|
21
|
+
* `verifyCompleted` invocation is a future enable: it needs the worker's `TaskResult` threaded to the oracle
|
|
22
|
+
* (core passes only the report `evidence` today), so it is deliberately NOT invoked here.
|
|
23
|
+
*
|
|
24
|
+
* The grader topology (graderEnv = the reused integration sandbox, oracle seeded ONLY there, worker env distinct)
|
|
25
|
+
* means the worker can never read the oracle; for SAFE-tier `candidate_only` the bare `graderEnv !== workerEnv`
|
|
26
|
+
* identity check is sufficient, so the caller OMITS `immutableOraclePaths` (the structural bash write-probe is
|
|
27
|
+
* vacuous across distinct sandboxes and matters only for the mandate-OFF auto-accept path — §10.2).
|
|
28
|
+
*/
|
|
1
29
|
import { runExecGate, } from "@sema-agent/core";
|
|
2
30
|
import { createHash } from "node:crypto";
|
|
31
|
+
/** Single-quote a string for safe interpolation into a shell command. */
|
|
3
32
|
const sq = (s) => `'${s.replace(/'/g, "'\\''")}'`;
|
|
33
|
+
/** A short, stable content hash for the stale-diff guard (fork2.1) + the graded-bytes binding (fork2.2). */
|
|
4
34
|
const sha = (s) => createHash("sha256").update(s).digest("hex").slice(0, 16);
|
|
35
|
+
/** Parse the changed file paths from a unified diff — the `diff --git a/X b/X` headers (both old + new path). */
|
|
5
36
|
function changedFilesOf(patch) {
|
|
6
37
|
const out = new Set();
|
|
7
38
|
for (const m of patch.matchAll(/^diff --git a\/(.+?) b\/(.+)$/gm)) {
|
|
@@ -11,6 +42,8 @@ function changedFilesOf(patch) {
|
|
|
11
42
|
return [...out];
|
|
12
43
|
}
|
|
13
44
|
const normP = (p) => p.replace(/^\.?\/+/, "").replace(/\/+$/, "");
|
|
45
|
+
/** fork1.2 — the first changed file that touches a protected oracle path (exact, or a subtree either way), else
|
|
46
|
+
* undefined. A patch that edits the grader's hidden-oracle/test path is refused (test-tampering guard). */
|
|
14
47
|
function touchesOraclePath(changed, oraclePaths) {
|
|
15
48
|
const ops = oraclePaths.map(normP).filter((p) => p !== "");
|
|
16
49
|
for (const f of changed.map(normP)) {
|
|
@@ -21,23 +54,35 @@ function touchesOraclePath(changed, oraclePaths) {
|
|
|
21
54
|
}
|
|
22
55
|
return undefined;
|
|
23
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Build the `RepairOracle` closure. The returned `(graderEnv, evidence) => OracleResult` is what the leader
|
|
59
|
+
* passes as `RepairLoopConfig.oracle`. `evidence` (the worker's report text) is intentionally unused — the
|
|
60
|
+
* closure recomputes the candidate diff from the worker env each call (§10.1).
|
|
61
|
+
*/
|
|
24
62
|
export function mkRepairOracle(cfg) {
|
|
25
63
|
const repo = cfg.graderRepoDir;
|
|
26
64
|
const K = Math.max(1, Math.floor(cfg.flakyK ?? 2));
|
|
27
|
-
let lastGradedHash;
|
|
65
|
+
let lastGradedHash; // fork2.1 stale-diff guard — per-loop state across the engine's attempts.
|
|
28
66
|
return async (graderEnv, _evidence) => {
|
|
67
|
+
// §10.1 — materialize the worker's LATEST code in a CLEAN grader tree. Pull fresh (never a stale diff).
|
|
29
68
|
const diff = await cfg.pullWorkerDiff();
|
|
30
69
|
if (!diff.ok) {
|
|
31
70
|
cfg.log?.("repair_oracle_pull_failed", { error: diff.error });
|
|
32
71
|
return { tier: cfg.passTier, passed: false, flaky: false, retries: 0, trace: `pull worker diff failed: ${diff.error}` };
|
|
33
72
|
}
|
|
34
73
|
const diffHash = sha(diff.patch);
|
|
74
|
+
// fork1.2 — refuse a candidate that edits a seeded oracle/test path: applied into the grader it
|
|
75
|
+
// could tamper the very oracle that grades it. Surface as `needs_human_oracle` (tier "none" → terminalForTier),
|
|
76
|
+
// never a silent candidate_only. (The §10.2 factory lane OMITs the engine path-probe, so this is the fence.)
|
|
35
77
|
const tampered = cfg.oraclePaths && cfg.oraclePaths.length > 0 ? touchesOraclePath(changedFilesOf(diff.patch), cfg.oraclePaths) : undefined;
|
|
36
78
|
if (tampered) {
|
|
37
79
|
cfg.log?.("repair_oracle_tampering_guard", { path: tampered });
|
|
38
80
|
cfg.onGraded?.({ diff: diff.patch, hash: diffHash, passed: false });
|
|
39
81
|
return { tier: "none", passed: false, flaky: false, retries: 0, trace: `candidate patch touches oracle/test path '${tampered}' — refusing to grade (fork1.2 test-tampering guard)` };
|
|
40
82
|
}
|
|
83
|
+
// fork2.1 — a repair attempt that produced NO new diff (byte-identical to the prior graded one)
|
|
84
|
+
// made no progress → never grade stale bytes as a fresh PASS: report no-progress (the loop gives up rather
|
|
85
|
+
// than re-passing a stale artifact). With fork2.2 this guarantees the SURFACED candidate == the graded bytes.
|
|
41
86
|
if (lastGradedHash !== undefined && diffHash === lastGradedHash) {
|
|
42
87
|
cfg.log?.("repair_oracle_stale_diff", { hash: diffHash });
|
|
43
88
|
cfg.onGraded?.({ diff: diff.patch, hash: diffHash, passed: false });
|
|
@@ -46,6 +91,8 @@ export function mkRepairOracle(cfg) {
|
|
|
46
91
|
lastGradedHash = diffHash;
|
|
47
92
|
const patchPath = `/tmp/candidate-${Date.now()}.patch`;
|
|
48
93
|
await cfg.graderWriteFile(patchPath, diff.patch);
|
|
94
|
+
// Hermetic prep: reset the grader to its clean base, then apply the FULL base→latest diff. `--whitespace=nowarn`
|
|
95
|
+
// matches the merge path (merge.ts:144). A prep failure (e.g. an apply conflict) is a non-flaky failed grade.
|
|
49
96
|
const prep = await runExecGate(graderEnv, [
|
|
50
97
|
{ command: `git -C ${sq(repo)} reset --hard ${sq(cfg.integBase)} && git -C ${sq(repo)} clean -fdx`, label: "grader-reset" },
|
|
51
98
|
{ command: `git -C ${sq(repo)} apply --whitespace=nowarn ${sq(patchPath)}`, label: "grader-apply" },
|
|
@@ -56,8 +103,15 @@ export function mkRepairOracle(cfg) {
|
|
|
56
103
|
cfg.onGraded?.({ diff: diff.patch, hash: diffHash, passed: false });
|
|
57
104
|
return { tier: cfg.passTier, passed: false, flaky: false, retries: 0, trace: `grader prep failed:\n${trace}` };
|
|
58
105
|
}
|
|
106
|
+
// 🔴 council 2026-06-17 — the hermetic `clean -fdx` above DELETED the seeded hidden oracle (untracked/ignored,
|
|
107
|
+
// never committed at integBase). RE-INJECT it AFTER applying the worker patch, so (a) the gate runs against the
|
|
108
|
+
// REAL oracle the clean wiped (else `trusted_hidden` is a false label), and (b) any file the patch placed at an
|
|
109
|
+
// oracle path is OVERWRITTEN by the trusted content (defence-in-depth with the fork1.2 path guard above).
|
|
59
110
|
for (const f of cfg.oracleFiles ?? [])
|
|
60
111
|
await cfg.graderWriteFile(f.path, f.content);
|
|
112
|
+
// L2 mechanical gate (the trusted hidden oracle), re-isolated K times to settle flakiness. A clear FIRST
|
|
113
|
+
// failure short-circuits (no point re-running a definite fail); a green verdict is re-run to detect a flaky
|
|
114
|
+
// (nondeterministic) test — a disagreement is reported flaky and core refuses to project it to a pass.
|
|
61
115
|
const verdicts = [];
|
|
62
116
|
let lastTrace = "";
|
|
63
117
|
for (let k = 0; k < K; k++) {
|
|
@@ -70,11 +124,15 @@ export function mkRepairOracle(cfg) {
|
|
|
70
124
|
}
|
|
71
125
|
const passed = verdicts.length > 0 && verdicts.every(Boolean);
|
|
72
126
|
const flaky = new Set(verdicts).size > 1;
|
|
127
|
+
// §10.9 — a self-certifying verifier (no distinct model) cannot CLEAR: a PASS downgrades to advisory. v1 has
|
|
128
|
+
// `cfg.l3` unset (L3 off) → the L2 `passTier` stands and `terminalForTier` caps the PASS at candidate_only.
|
|
73
129
|
let tier = cfg.passTier;
|
|
74
130
|
if (cfg.l3 && passed && !flaky && cfg.l3.verifierModelId === cfg.l3.generatorModelId) {
|
|
75
131
|
cfg.log?.("repair_oracle_l3_decorrelation_failed", { model: cfg.l3.generatorModelId });
|
|
76
132
|
tier = "l3_judge_advisory";
|
|
77
133
|
}
|
|
134
|
+
// fork2.2 — bind the EXACT graded bytes (the diff that produced this verdict) so the caller surfaces the
|
|
135
|
+
// candidate the human reviews == the bytes that were graded (not a later re-pull that may differ).
|
|
78
136
|
cfg.onGraded?.({ diff: diff.patch, hash: diffHash, passed });
|
|
79
137
|
cfg.log?.("repair_oracle_verdict", { tier, passed, flaky, retries: K });
|
|
80
138
|
return { tier, passed, flaky, retries: K, ...(passed && !flaky ? {} : { trace: lastTrace || "oracle rejected the candidate" }) };
|
|
@@ -1,30 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WIRE that wraps core `runRepairLoop` onto the leader's single-agent path
|
|
3
|
+
* (`docs/LEADER-REPAIRLOOP-INTEGRATION.md` §3.3 + the authoritative §10 layer). It owns the three things the
|
|
4
|
+
* `RepairOracle` closure (`repair-oracle.ts`) and the core engine CANNOT resolve themselves:
|
|
5
|
+
*
|
|
6
|
+
* 1. **The grader handle (R1, §10.1)** — the reused integration sandbox's writeFile/exec + `integBase`, bound by
|
|
7
|
+
* the caller (`attachRepairLoopDeps` is handed the integration env). The closure grades there; the worker env
|
|
8
|
+
* stays distinct so the §5.1 identity check (`graderEnv !== workerEnv`) is LIVE.
|
|
9
|
+
* 2. **The worker diff source** — `pullWorkerDiff`, the same `pullDiff`/self-upload path the merge uses, so the
|
|
10
|
+
* closure materializes the worker's LATEST committed `base..HEAD` diff every grade (§10.1; never a stale diff).
|
|
11
|
+
* 3. **De-correlation model ids (§10.9 mechanics)** — the closure receives NO model ids (roles→models resolve
|
|
12
|
+
* INSIDE `Runner.runTask`, AFTER the closure returns), so the WIRE resolves `generatorModelId` +
|
|
13
|
+
* `verifierModelId` from `cfg.roles`/`cfg.models` and passes them to `mkRepairOracle.l3`. v1 ships L3 OFF
|
|
14
|
+
* (`cfg.l3` unset) → L2 `trusted_hidden` is the sole clearer; `terminalForTier` caps every PASS at
|
|
15
|
+
* `candidate_only`.
|
|
16
|
+
*
|
|
17
|
+
* §10.2 — for v1 SAFE-tier `candidate_only` we OMIT `immutableOraclePaths` (the bare `graderEnv !== workerEnv`
|
|
18
|
+
* identity check suffices; the structural bash write-probe is vacuous across distinct sandboxes and matters only
|
|
19
|
+
* for the mandate-OFF auto-accept path). `workerEnv` IS passed so the identity check runs.
|
|
20
|
+
*
|
|
21
|
+
* §10.7 — the surfaced `candidatePatch.patch` is worker-authored code reaching a human-read HTTP body / durable-
|
|
22
|
+
* approval row, so it is DELIMITED (`delimitUntrusted(...)`); `reason` comes ONLY from the core-sanitized
|
|
23
|
+
* `RepairResult.verification.findings[0]`, never the raw oracle trace.
|
|
24
|
+
*
|
|
25
|
+
* §10.8 — `attachRepairLoopDeps(deps, integEnv, cfg)` is the SINGLE wire-call helper so `wire.ts` gains one line
|
|
26
|
+
* per integration-sandbox path instead of in-place edits to its dense provision spreads. Stage-2 calls it.
|
|
27
|
+
*
|
|
28
|
+
* Everything here is gated by the caller behind `LEADER_REPAIR_LOOP` (default OFF): when the dep is not attached
|
|
29
|
+
* the leader's single-agent paths are byte-identical to today.
|
|
30
|
+
*/
|
|
1
31
|
import { type Runner, type TaskSpec, type ExecutionEnv, type ExecStep, type OracleTier, type RepairResult, type RepairBundle, type RepairTerminal } from "@sema-agent/core";
|
|
2
32
|
import { type WorkerDiff } from "./repair-oracle.js";
|
|
3
33
|
import type { GraderHandle } from "./grader-env-factory.js";
|
|
4
34
|
import type { LeaderDeps, ProvisionedWorker, SubtaskSpec } from "./leader.js";
|
|
5
35
|
import type { WorkerReport } from "./fanout.js";
|
|
36
|
+
/** The per-run inputs the leader's single-agent repair loop needs, resolved by the wire (§3.3). */
|
|
6
37
|
export interface RepairWireCfg {
|
|
38
|
+
/** The CONCRETE core Runner that runs the solo worker's GENERATE/REPAIR turns. `runRepairLoop` requires the
|
|
39
|
+
* real `Runner` (not the `RunnerLike` on `ProvisionedWorker`); the wire holds it (it builds the worker Runner). */
|
|
7
40
|
runner: Runner;
|
|
41
|
+
/** The grader handle (R1: the reused integration sandbox) — writeFile/exec/repoDir/integBase bound by the wire. */
|
|
8
42
|
grader: GraderHandle;
|
|
43
|
+
/** OPTIONAL solo worker execution env REF — passed as `runRepairLoop.workerEnv` so the §5.1 identity check is
|
|
44
|
+
* LIVE. On the FACTORY lane (REMOTE_EXEC=e2b/k8s — the canary) the worker's RAW env is NOT surfaced (only
|
|
45
|
+
* `fetchDiff`), so it is OMITTED: `runRepairLoop` then SKIPS the identity check (fires `onWarn` — fine).
|
|
46
|
+
* Structural isolation is GUARANTEED regardless because the grader is a SEPARATE provisioned sandbox (a
|
|
47
|
+
* distinct object / `sandboxId` from the worker by construction) — §10.2: the identity check is necessary-not-
|
|
48
|
+
* sufficient; the real boundary is the separate sandbox. Present on the STATIC E2B lane (the leader owns the
|
|
49
|
+
* worker env). When present it is forwarded; when absent runRepairLoop is called without `workerEnv`. */
|
|
9
50
|
workerEnv?: ExecutionEnv;
|
|
51
|
+
/** Reap the dedicated grader sandbox the wire provisioned for THIS repair loop (called in a `finally` on every
|
|
52
|
+
* path — the grader is a separate sandbox the leader owns, distinct from the worker + the integration sandbox). */
|
|
10
53
|
graderDestroy?: () => Promise<void>;
|
|
54
|
+
/** Pull the worker's LATEST committed `base..HEAD` diff from ITS env (the merge `pullDiff`/self-upload path). */
|
|
11
55
|
pullWorkerDiff: () => Promise<WorkerDiff>;
|
|
56
|
+
/** TRUSTED, spec-derived oracle steps run in the grader (`testCmd` [+ `measureCmd`]); NEVER worker-authored. */
|
|
12
57
|
oracleSteps: ExecStep[];
|
|
58
|
+
/** The tier assigned on a PASS — `trusted_hidden` when the steps run an oracleFiles-backed hidden oracle,
|
|
59
|
+
* `property_harness_weak` for a compile-only gate, `none` if there is no usable oracle. */
|
|
13
60
|
passTier: OracleTier;
|
|
61
|
+
/** council 2026-06-17 — the seeded hidden-oracle files (content), RE-INJECTED after each hermetic reset+apply so
|
|
62
|
+
* the `clean -fdx` doesn't grade against a wiped/worker-substituted oracle. Empty for an inline-testCmd gate. */
|
|
14
63
|
oracleFiles?: Array<{
|
|
15
64
|
path: string;
|
|
16
65
|
content: string;
|
|
17
66
|
}>;
|
|
67
|
+
/** fork1.2 — paths the candidate patch must not touch (the oracle/test paths); a touch → `needs_human_oracle`. */
|
|
18
68
|
oraclePaths?: string[];
|
|
69
|
+
/** In-loop attempt ceiling (LEADER_REPAIR_LOOP_ATTEMPTS, validated 2-3 by the wire). */
|
|
19
70
|
maxAttempts: number;
|
|
71
|
+
/** K re-isolations to settle a flaky verdict (LEADER_ORACLE_FLAKY_K, default 2). */
|
|
20
72
|
flakyK?: number;
|
|
73
|
+
/** Cost/time backstops forwarded to `runRepairLoop`. */
|
|
21
74
|
costCeilingMicroUsd?: number;
|
|
22
75
|
totalTimeoutMs?: number;
|
|
76
|
+
/** §10.5 resume threading: the restored `RepairBundle` from a resumed checkpoint (`repairBundleFromCheckpoint`),
|
|
77
|
+
* re-seeded MONOTONICALLY. v1 makes the repair path mutually exclusive with resource-suspend (the wire drops
|
|
78
|
+
* `resourceSpec` when `repairLoopActive`), so this is usually undefined; threaded for the future resume path. */
|
|
23
79
|
resumeBundle?: RepairBundle;
|
|
80
|
+
/** §10.9 — the resolved generator+verifier model ids for the L3 de-correlation gate. v1 leaves L3 OFF (unset). */
|
|
24
81
|
l3?: {
|
|
25
82
|
generatorModelId: string;
|
|
26
83
|
verifierModelId: string;
|
|
27
84
|
};
|
|
85
|
+
/** Per-attempt observability callback. */
|
|
28
86
|
onAttempt?: (info: {
|
|
29
87
|
attempt: number;
|
|
30
88
|
terminal?: RepairTerminal;
|
|
@@ -34,6 +92,7 @@ export interface RepairWireCfg {
|
|
|
34
92
|
}) => void;
|
|
35
93
|
log?: (event: string, x?: Record<string, unknown>) => void;
|
|
36
94
|
}
|
|
95
|
+
/** A leader-mapped repair outcome: the report (carrying `repairTerminal` — §10.6) + the raw result + held candidate. */
|
|
37
96
|
export interface RepairWireOutcome {
|
|
38
97
|
report: WorkerReport;
|
|
39
98
|
result: RepairResult;
|
|
@@ -44,6 +103,25 @@ export interface RepairWireOutcome {
|
|
|
44
103
|
gradedHash?: string;
|
|
45
104
|
};
|
|
46
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* §3.3 — run the bounded single-agent self-repair loop over the solo worker and map the result to a `WorkerReport`
|
|
108
|
+
* (with `repairTerminal` set — §10.6). Builds the `RepairOracle` closure (capturing the worker-diff source, the
|
|
109
|
+
* grader handle, `integBase`, the trusted steps, the resolved model ids), then calls `runRepairLoop` with
|
|
110
|
+
* `graderEnv` = the integration sandbox, `workerEnv` = the solo worker's env (so the identity check is LIVE),
|
|
111
|
+
* OMITTING `immutableOraclePaths` (§10.2). Never throws — a thrown engine error maps to a `failed` report so the
|
|
112
|
+
* leader's "never throws" contract holds. The held candidate (`candidate_only` etc.) is surfaced DELIMITED (§10.7).
|
|
113
|
+
*/
|
|
47
114
|
export declare function runRepairLoopForLeader(solo: ProvisionedWorker, implSpec: TaskSpec, cfg: RepairWireCfg): Promise<RepairWireOutcome>;
|
|
115
|
+
/**
|
|
116
|
+
* §10.8 — the SINGLE wire-call helper. Attaches the `LeaderDeps.repairLoop` dep (the opt-in single-agent repair
|
|
117
|
+
* loop) using the integration sandbox as the grader (R1). `wire.ts` calls this ONCE per integration-sandbox path
|
|
118
|
+
* instead of editing its dense provision spreads. When `cfg` is absent (LEADER_REPAIR_LOOP off) it is a NO-OP →
|
|
119
|
+
* `deps.repairLoop` stays unset → the leader's single-agent paths are byte-identical to today.
|
|
120
|
+
*
|
|
121
|
+
* The wire supplies a `resolve(solo, sub)` that, per solo worker, produces the concrete `RepairWireCfg` (the real
|
|
122
|
+
* Runner + the worker env ref + the worker diff source bound to THAT worker). Kept as a callback so the grader
|
|
123
|
+
* handle / steps / model ids the wire already holds are closed over once, and only the per-worker bindings are
|
|
124
|
+
* resolved at call time.
|
|
125
|
+
*/
|
|
48
126
|
export declare function attachRepairLoopDeps(deps: LeaderDeps, resolve: ((solo: ProvisionedWorker, sub: SubtaskSpec) => Promise<RepairWireCfg>) | undefined): void;
|
|
49
127
|
//# sourceMappingURL=repair-wire.d.ts.map
|
|
@@ -1,19 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WIRE that wraps core `runRepairLoop` onto the leader's single-agent path
|
|
3
|
+
* (`docs/LEADER-REPAIRLOOP-INTEGRATION.md` §3.3 + the authoritative §10 layer). It owns the three things the
|
|
4
|
+
* `RepairOracle` closure (`repair-oracle.ts`) and the core engine CANNOT resolve themselves:
|
|
5
|
+
*
|
|
6
|
+
* 1. **The grader handle (R1, §10.1)** — the reused integration sandbox's writeFile/exec + `integBase`, bound by
|
|
7
|
+
* the caller (`attachRepairLoopDeps` is handed the integration env). The closure grades there; the worker env
|
|
8
|
+
* stays distinct so the §5.1 identity check (`graderEnv !== workerEnv`) is LIVE.
|
|
9
|
+
* 2. **The worker diff source** — `pullWorkerDiff`, the same `pullDiff`/self-upload path the merge uses, so the
|
|
10
|
+
* closure materializes the worker's LATEST committed `base..HEAD` diff every grade (§10.1; never a stale diff).
|
|
11
|
+
* 3. **De-correlation model ids (§10.9 mechanics)** — the closure receives NO model ids (roles→models resolve
|
|
12
|
+
* INSIDE `Runner.runTask`, AFTER the closure returns), so the WIRE resolves `generatorModelId` +
|
|
13
|
+
* `verifierModelId` from `cfg.roles`/`cfg.models` and passes them to `mkRepairOracle.l3`. v1 ships L3 OFF
|
|
14
|
+
* (`cfg.l3` unset) → L2 `trusted_hidden` is the sole clearer; `terminalForTier` caps every PASS at
|
|
15
|
+
* `candidate_only`.
|
|
16
|
+
*
|
|
17
|
+
* §10.2 — for v1 SAFE-tier `candidate_only` we OMIT `immutableOraclePaths` (the bare `graderEnv !== workerEnv`
|
|
18
|
+
* identity check suffices; the structural bash write-probe is vacuous across distinct sandboxes and matters only
|
|
19
|
+
* for the mandate-OFF auto-accept path). `workerEnv` IS passed so the identity check runs.
|
|
20
|
+
*
|
|
21
|
+
* §10.7 — the surfaced `candidatePatch.patch` is worker-authored code reaching a human-read HTTP body / durable-
|
|
22
|
+
* approval row, so it is DELIMITED (`delimitUntrusted(...)`); `reason` comes ONLY from the core-sanitized
|
|
23
|
+
* `RepairResult.verification.findings[0]`, never the raw oracle trace.
|
|
24
|
+
*
|
|
25
|
+
* §10.8 — `attachRepairLoopDeps(deps, integEnv, cfg)` is the SINGLE wire-call helper so `wire.ts` gains one line
|
|
26
|
+
* per integration-sandbox path instead of in-place edits to its dense provision spreads. Stage-2 calls it.
|
|
27
|
+
*
|
|
28
|
+
* Everything here is gated by the caller behind `LEADER_REPAIR_LOOP` (default OFF): when the dep is not attached
|
|
29
|
+
* the leader's single-agent paths are byte-identical to today.
|
|
30
|
+
*/
|
|
1
31
|
import { runRepairLoop, delimitUntrusted, } from "@sema-agent/core";
|
|
2
32
|
import { mkRepairOracle } from "./repair-oracle.js";
|
|
33
|
+
/**
|
|
34
|
+
* §10.6 status mapping. A SAFE-tier `candidate_only`/`fixed` maps to status `completed` (back-compat — there is no
|
|
35
|
+
* `candidate_only` status member; the candidate state rides on `repairTerminal`, and the merge push chokepoint
|
|
36
|
+
* holds the push). Every other terminal is a NON-mergeable abstain/failure → `failed` (quarantined), carrying the
|
|
37
|
+
* terminal as the WHY (no-silent-failures). `gave_up`/`oracle.unprotected` → `failed`; `needs_human_oracle`/
|
|
38
|
+
* `conflict` → `failed` too (the HTTP layer re-reads `repairTerminal` to surface `needs_human`, `endpoint.ts:75`).
|
|
39
|
+
*/
|
|
3
40
|
function statusForTerminal(t) {
|
|
4
41
|
return t === "fixed" || t === "candidate_only" ? "completed" : "failed";
|
|
5
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* §3.3 — run the bounded single-agent self-repair loop over the solo worker and map the result to a `WorkerReport`
|
|
45
|
+
* (with `repairTerminal` set — §10.6). Builds the `RepairOracle` closure (capturing the worker-diff source, the
|
|
46
|
+
* grader handle, `integBase`, the trusted steps, the resolved model ids), then calls `runRepairLoop` with
|
|
47
|
+
* `graderEnv` = the integration sandbox, `workerEnv` = the solo worker's env (so the identity check is LIVE),
|
|
48
|
+
* OMITTING `immutableOraclePaths` (§10.2). Never throws — a thrown engine error maps to a `failed` report so the
|
|
49
|
+
* leader's "never throws" contract holds. The held candidate (`candidate_only` etc.) is surfaced DELIMITED (§10.7).
|
|
50
|
+
*/
|
|
6
51
|
export async function runRepairLoopForLeader(solo, implSpec, cfg) {
|
|
7
52
|
try {
|
|
8
53
|
return await runRepairLoopForLeaderInner(solo, implSpec, cfg);
|
|
9
54
|
}
|
|
10
55
|
finally {
|
|
56
|
+
// Reap the dedicated grader sandbox on EVERY path (success, abstain, or a thrown engine error). The grader is
|
|
57
|
+
// a separate provisioned sandbox the wire minted for this loop; the inner fn never throws (its own try/catch
|
|
58
|
+
// maps an engine error to a failed report), so this `finally` runs once per loop.
|
|
11
59
|
if (cfg.graderDestroy)
|
|
12
60
|
await cfg.graderDestroy().catch(() => { });
|
|
13
61
|
}
|
|
14
62
|
}
|
|
15
63
|
async function runRepairLoopForLeaderInner(solo, implSpec, cfg) {
|
|
16
64
|
const base = { workerId: solo.workerId, sessionId: solo.sessionId, branch: solo.branch, baseSha: solo.baseSha };
|
|
65
|
+
// fork2.2 — capture the EXACT bytes the oracle graded (the last verdict) so the surfaced
|
|
66
|
+
// candidate == the graded artifact: a human reviews the bytes that produced the terminal, never a later re-pull
|
|
67
|
+
// that may have drifted. Updated on every oracle call; the last one is the artifact the terminal is about.
|
|
17
68
|
let graded;
|
|
18
69
|
const oracle = mkRepairOracle({
|
|
19
70
|
pullWorkerDiff: cfg.pullWorkerDiff,
|
|
@@ -22,7 +73,7 @@ async function runRepairLoopForLeaderInner(solo, implSpec, cfg) {
|
|
|
22
73
|
integBase: cfg.grader.integBase,
|
|
23
74
|
oracleSteps: cfg.oracleSteps,
|
|
24
75
|
passTier: cfg.passTier,
|
|
25
|
-
...(cfg.oraclePaths ? { oraclePaths: cfg.oraclePaths } : {}),
|
|
76
|
+
...(cfg.oraclePaths ? { oraclePaths: cfg.oraclePaths } : {}), // fork1.2 — refuse a patch that touches the oracle
|
|
26
77
|
onGraded: (info) => { graded = { diff: info.diff, hash: info.hash }; },
|
|
27
78
|
...(cfg.flakyK !== undefined ? { flakyK: cfg.flakyK } : {}),
|
|
28
79
|
...(cfg.l3 ? { l3: cfg.l3 } : {}),
|
|
@@ -33,6 +84,11 @@ async function runRepairLoopForLeaderInner(solo, implSpec, cfg) {
|
|
|
33
84
|
result = await runRepairLoop(cfg.runner, implSpec, {
|
|
34
85
|
oracle,
|
|
35
86
|
graderEnv: cfg.grader.env,
|
|
87
|
+
// §10.2 — pass workerEnv ONLY when present (the static E2B lane, where the leader owns the worker env) so
|
|
88
|
+
// the LIVE identity check runs; OMIT it on the factory lane where the worker's raw env is not surfaced
|
|
89
|
+
// (runRepairLoop then SKIPS the check + fires onWarn — fine, the grader is a separate sandbox by
|
|
90
|
+
// construction). Either way OMIT immutableOraclePaths (the structural probe is vacuous across distinct
|
|
91
|
+
// sandboxes; the bare graderEnv !== workerEnv check is sufficient SAFE-tier).
|
|
36
92
|
...(cfg.workerEnv ? { workerEnv: cfg.workerEnv } : {}),
|
|
37
93
|
maxAttempts: cfg.maxAttempts,
|
|
38
94
|
...(cfg.resumeBundle ? { resumeBundle: cfg.resumeBundle } : {}),
|
|
@@ -56,8 +112,15 @@ async function runRepairLoopForLeaderInner(solo, implSpec, cfg) {
|
|
|
56
112
|
...(result.stats ? { stats: result.stats } : {}),
|
|
57
113
|
...(result.errorMessage ? { error: result.errorMessage } : {}),
|
|
58
114
|
};
|
|
115
|
+
// §10.7 — surface a held candidate DELIMITED. `reason` is sourced ONLY from the core-sanitized verification
|
|
116
|
+
// findings (never the raw oracle trace tail, which is untrusted worker-adjacent text). Surface on any non-
|
|
117
|
+
// auto-accepting terminal that still carries usable worker output (candidate_only / needs_human_oracle /
|
|
118
|
+
// gave_up / conflict). `oracle.unprotected` is an infra-isolation failure → no candidate to surface.
|
|
59
119
|
let candidatePatch;
|
|
60
120
|
if (terminal !== "oracle.unprotected" && terminal !== "fixed") {
|
|
121
|
+
// fork2.2 — surface the EXACT bytes the oracle graded (the last verdict's diff + its hash), so the human
|
|
122
|
+
// reviews the artifact that produced this terminal — never a later re-pull that may have drifted. Fall back
|
|
123
|
+
// to a fresh pull only if the loop somehow reached here without a graded diff (defensive; hash unknown).
|
|
61
124
|
const g = graded ??
|
|
62
125
|
(await (async () => {
|
|
63
126
|
const d = await cfg.pullWorkerDiff().catch((e) => ({ ok: false, error: e instanceof Error ? e.message : String(e) }));
|
|
@@ -76,11 +139,25 @@ async function runRepairLoopForLeaderInner(solo, implSpec, cfg) {
|
|
|
76
139
|
cfg.log?.("repair_loop_outcome", { terminal, status: report.status, hasCandidate: candidatePatch !== undefined });
|
|
77
140
|
return { report, result, ...(candidatePatch ? { candidatePatch } : {}) };
|
|
78
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* §10.8 — the SINGLE wire-call helper. Attaches the `LeaderDeps.repairLoop` dep (the opt-in single-agent repair
|
|
144
|
+
* loop) using the integration sandbox as the grader (R1). `wire.ts` calls this ONCE per integration-sandbox path
|
|
145
|
+
* instead of editing its dense provision spreads. When `cfg` is absent (LEADER_REPAIR_LOOP off) it is a NO-OP →
|
|
146
|
+
* `deps.repairLoop` stays unset → the leader's single-agent paths are byte-identical to today.
|
|
147
|
+
*
|
|
148
|
+
* The wire supplies a `resolve(solo, sub)` that, per solo worker, produces the concrete `RepairWireCfg` (the real
|
|
149
|
+
* Runner + the worker env ref + the worker diff source bound to THAT worker). Kept as a callback so the grader
|
|
150
|
+
* handle / steps / model ids the wire already holds are closed over once, and only the per-worker bindings are
|
|
151
|
+
* resolved at call time.
|
|
152
|
+
*/
|
|
79
153
|
export function attachRepairLoopDeps(deps, resolve) {
|
|
80
154
|
if (!resolve)
|
|
81
|
-
return;
|
|
155
|
+
return; // LEADER_REPAIR_LOOP off → no-op → byte-identical default path
|
|
82
156
|
deps.repairLoop = {
|
|
83
157
|
run: async (solo, sub) => {
|
|
158
|
+
// `resolve` is ASYNC: it provisions a DEDICATED grader sandbox (seed + inject-oracle) for THIS loop, which
|
|
159
|
+
// is async. The grader lifecycle (destroy) rides on the returned `RepairWireCfg.graderDestroy`, reaped in
|
|
160
|
+
// `runRepairLoopForLeader`'s `finally`.
|
|
84
161
|
const cfg = await resolve(solo, sub);
|
|
85
162
|
const implSpec = { ...sub.spec, sessionId: solo.sessionId };
|
|
86
163
|
return runRepairLoopForLeader(solo, implSpec, cfg);
|
package/dist/leader/wire.d.ts
CHANGED
|
@@ -3,8 +3,16 @@ import type { CheckpointStoreFull } from "../plugins/store-backend.js";
|
|
|
3
3
|
import { type LeaderResult } from "./leader.js";
|
|
4
4
|
import type { LeaderRequestBody } from "./endpoint.js";
|
|
5
5
|
export interface LeaderWireConfig {
|
|
6
|
+
/** Static-env compat mode (E2B only): the leader provisions/owns each env. Required when `envFactory` unset. */
|
|
6
7
|
e2bApiKey?: string;
|
|
8
|
+
/** design/68 F2(a) + k8s lane: the per-task execution-env factory the service main already built for
|
|
9
|
+
* REMOTE_EXEC (e2b or k8s/Kata) — workers and the integration sandbox run on envs from THIS factory.
|
|
10
|
+
* Requires `s3` (diff-out is the worker's self-upload; there is no leader-held env to pull from). */
|
|
7
11
|
envFactory?: ExecutionEnvFactory;
|
|
12
|
+
/** Durable suspend/resume for SUB-WORKERS (design/68 C4): when set, each worker task carries the durable
|
|
13
|
+
* question/ask policy + checkpoint store, so a gated ask/AskUserQuestion SUSPENDS the worker (checkpoint +
|
|
14
|
+
* paused env) instead of failing — the trigger replan-lite C4 arbitrates on. Mirrors main.ts's per-task
|
|
15
|
+
* durable wiring; ctx is seeded at provision so the surfaced token is resumable on the single-agent path. */
|
|
8
16
|
durable?: {
|
|
9
17
|
checkpointStore: CheckpointStoreFull;
|
|
10
18
|
requireApproval: string[];
|
|
@@ -13,21 +21,48 @@ export interface LeaderWireConfig {
|
|
|
13
21
|
autoBudget?: number;
|
|
14
22
|
neverAuto?: string[];
|
|
15
23
|
};
|
|
24
|
+
/** Durable tool-result offload store (TiDB). REQUIRED for `durable` to actually suspend: core's suspend
|
|
25
|
+
* pre-commit refuses with the default InMemoryToolResultStore (offloaded results would deref to null after
|
|
26
|
+
* a cross-replica resume) and silently falls back to the synchronous onAsk gate — which the leader does not
|
|
27
|
+
* wire, so the gated call is denied and the worker FAILS instead of suspending (found live: drill c3). */
|
|
16
28
|
toolResultStore?: ToolResultStore;
|
|
29
|
+
/** Durable session store (TiDB). Same durable-resume requirement as `toolResultStore`: a suspended sub-worker's
|
|
30
|
+
* session history must be readable by the MAIN runner on /decide resume — with the per-wire in-memory default
|
|
31
|
+
* the resume dies with SessionError "Entry <leafId> not found" (found live: drill c3 deny path). */
|
|
17
32
|
sessionStore?: SessionStore;
|
|
33
|
+
/** Worker model brain + catalog (the same the service runs tasks on). */
|
|
18
34
|
brain: Brain;
|
|
19
35
|
models: Record<string, Model>;
|
|
20
36
|
roles: ModelRoles;
|
|
21
37
|
pricing: Record<string, ModelPricing>;
|
|
38
|
+
/** Workspace root inside each E2B VM. Default /home/user. */
|
|
22
39
|
workspace?: string;
|
|
40
|
+
/** Git identity for the Coordinator's local clone/commit. */
|
|
23
41
|
git?: {
|
|
24
42
|
name: string;
|
|
25
43
|
email: string;
|
|
26
44
|
};
|
|
45
|
+
/** design/68 A6 knob: false = router never fans out (deterministic single route, zero router cost). */
|
|
27
46
|
fanoutEnabled?: boolean;
|
|
47
|
+
/** The model (a catalog name) the ROUTER/planner call runs on. The route is a trivial single-vs-fanout
|
|
48
|
+
* classification; running it on a heavy reasoning model (deepseek-v4-pro + reasoning) returns an EMPTY
|
|
49
|
+
* completion ~2/3 of the time — the budget is spent on reasoning with no answer text → "not valid JSON" →
|
|
50
|
+
* collapse-to-single, silently defeating fan-out (search 2026-06-14, reproduced 3×). A cheap non-reasoning
|
|
51
|
+
* model (deepseek-v4-flash) routes correctly 51/51 in probes. Unset → the route runs on the default model. */
|
|
28
52
|
routerModel?: string;
|
|
53
|
+
/** Max bounded integration-repair rounds on a clean-merge-but-failing-build (see merge.ts IntegrationRepair).
|
|
54
|
+
* 0 / unset = OFF (a failing integration test is terminal, the pre-2026-06-14 behavior). Env override:
|
|
55
|
+
* LEADER_REPAIR_ROUNDS. Repair runs the strong (default) model with hands in the live merged sandbox. */
|
|
29
56
|
repairRounds?: number;
|
|
57
|
+
/** Max bounded merge-conflict-resolution rounds on a `git apply --3way` conflict (see merge.ts ConflictResolver).
|
|
58
|
+
* 0 / unset = OFF (an apply conflict collapses the whole run to a single worker, the pre-2026-06-16 behavior).
|
|
59
|
+
* Env override: LEADER_CONFLICT_ROUNDS. Resolves the conflict in-place + keeps the other workers' work, instead
|
|
60
|
+
* of discarding all fan-out output and redoing single. Runs the strong (default) model with hands in the sandbox. */
|
|
30
61
|
conflictRounds?: number;
|
|
62
|
+
/** design/68 §8 F2(a): when set, workers run on FACTORY envs (runner-owned lifecycle — the durable-suspend-
|
|
63
|
+
* complete path; a suspended worker's paused env is exempt from the leader reap by construction) and diff-out
|
|
64
|
+
* is the worker's mandatory self-upload to this MinIO/S3 store (presigned per worker; creds adapter-held).
|
|
65
|
+
* Unset = the original leader-owned static-env mode (pullDiff compat). */
|
|
31
66
|
s3?: {
|
|
32
67
|
endpoint: string;
|
|
33
68
|
bucket: string;
|
|
@@ -41,7 +76,38 @@ export interface LeaderWireConfig {
|
|
|
41
76
|
info?: (m: string, x?: Record<string, unknown>) => void;
|
|
42
77
|
};
|
|
43
78
|
}
|
|
79
|
+
/** The env surface wire needs (both the E2B and k8s adapters implement core's RemoteExecutionEnv). */
|
|
44
80
|
type WireEnv = Pick<RemoteExecutionEnv, "exec" | "writeFile">;
|
|
81
|
+
/**
|
|
82
|
+
* Resume-safe worker staging (the design/68 F2(a) factory-env path). Runs adapter-side before the agent's
|
|
83
|
+
* first workspace-touching call: seed the base repo at the worker branch + plant the upload script (so the
|
|
84
|
+
* presigned URL never passes through the model).
|
|
85
|
+
*
|
|
86
|
+
* 🔴 BL-1 fix (design/74 Slice 6): on a RESOURCE-SUSPEND RESUME core re-invokes the `executionEnvFactory`,
|
|
87
|
+
* producing a FRESH `withStaging` wrapper (`staged=undefined`) whose `stage()` runs AGAIN — AFTER core's
|
|
88
|
+
* `resumeVM()` has already untar'd the snapshot onto the fresh pod (`resumeVM` is not a STAGED_METHOD, so it
|
|
89
|
+
* is NOT intercepted by the staging proxy; the agent's first `exec` is what triggers `stage()`, lazily, and
|
|
90
|
+
* by then the snapshot is restored). The old `stage()` ran the seed UNCONDITIONALLY:
|
|
91
|
+
* `${seedCmd}; cd ${repo}; git checkout -q -b ${branch}`
|
|
92
|
+
* and `seedCmd` begins with `rm -rf /workspace/repo` — so it WIPED the just-restored snapshot and re-seeded at
|
|
93
|
+
* `baseSha`, then created the worker branch at base. The forensic proof (leaderRunId 019ecda7): the suspend
|
|
94
|
+
* snapshot object DID contain the worker's commit (`git log` in the S3 tarball = the real progress), yet every
|
|
95
|
+
* resumed slice's `git log` showed only the base commit — the worker rebuilt destroyed work for ~47 min. THIS
|
|
96
|
+
* (a staging re-seed clobbering a correctly-restored snapshot) is the dominant cause of failed make-real runs.
|
|
97
|
+
*
|
|
98
|
+
* The fix = a RESTORED-SNAPSHOT SENTINEL that no-ops staging on resume. The robust signal is the upload-script
|
|
99
|
+
* MARKER FILE (`uploadScriptPath`): staging itself plants it, so it is present in EVERY restored snapshot
|
|
100
|
+
* (verified: it survives in both a base-state in-progress snapshot AND a post-commit one) and ABSENT on a
|
|
101
|
+
* genuinely fresh pod — and it is INDEPENDENT of git/commit state. That last point matters: a worker can
|
|
102
|
+
* suspend with work in progress but no commit yet (HEAD still == baseSha), so a "HEAD advanced past baseSha"
|
|
103
|
+
* probe alone would WRONGLY re-seed+clobber that valid snapshot. The marker captures "staging already ran here"
|
|
104
|
+
* regardless of whether a commit landed. We additionally accept the worker branch already existing as a
|
|
105
|
+
* secondary restored-snapshot signal (belt-and-suspenders for the same git-state-independent reason).
|
|
106
|
+
*
|
|
107
|
+
* A FRESH pod has neither marker nor branch → full staging runs. A probe transport failure falls through to
|
|
108
|
+
* full staging too (fails honestly via `sh()`, never silently skips). `branch`/paths are `validateSubtasks`-
|
|
109
|
+
* clean / deployment config and are JSON-quoted under `bash -lc` regardless. Exported for the regression test.
|
|
110
|
+
*/
|
|
45
111
|
export declare function stageWorkerEnv(env: WireEnv, opts: {
|
|
46
112
|
seedCmd: string;
|
|
47
113
|
repo: string;
|
|
@@ -49,12 +115,25 @@ export declare function stageWorkerEnv(env: WireEnv, opts: {
|
|
|
49
115
|
uploadScriptPath: string;
|
|
50
116
|
uploadScript: string;
|
|
51
117
|
}): Promise<void>;
|
|
118
|
+
/** Build the `runLeader(body)` the HTTP endpoint invokes. Constructs real per-task deps + runs the leader. */
|
|
119
|
+
/**
|
|
120
|
+
* Per-leader-run resource bounds derived from env (2026-06-14). Exported for unit tests. The worker sandbox
|
|
121
|
+
* lifetime (BUG2), the worker's diff-upload presigned-URL TTL (BUG1), and the worker spec's triple bound
|
|
122
|
+
* (maxTurns/timeoutSec/maxCostUsd, #15) ALL track one `leaderTimeoutMs` — a hardcoded 10min (sandbox) or 1h
|
|
123
|
+
* (URL) silently killed long autonomous builds or expired the diff upload mid-run. core's turn cap is now a
|
|
124
|
+
* high net (10000), so the leader gives each worker an explicit triple bound; a sub-task's own limits override.
|
|
125
|
+
*/
|
|
52
126
|
export declare function leaderResourceConfig(env?: NodeJS.ProcessEnv): {
|
|
53
127
|
leaderTimeoutMs: number;
|
|
54
128
|
workerMaxTurns: number;
|
|
55
129
|
workerBudgetUsd: number;
|
|
56
130
|
workerLimits: Partial<TaskSpec>;
|
|
57
131
|
presignTtlSec: number;
|
|
132
|
+
/** design/74 Slice 6: opt-in (LEADER_RESOURCE_SUSPEND=true) resource-slice suspend for workers. When set, a
|
|
133
|
+
* worker SUSPENDS at the per-slice window (`sliceMaxCostUsd`) instead of failing at the budget, and the
|
|
134
|
+
* leader auto-resumes (resumeWithVerification) until the TOTAL (`totalBudgetUsd` = workerBudgetUsd) is spent
|
|
135
|
+
* — a budget overrun becomes a resumable pause, not a worker failure. `maxSuspends` is sized to the slice
|
|
136
|
+
* count (+margin) so the suspend-loop cap doesn't fire before the budget is legitimately spent. */
|
|
58
137
|
resourceSuspend?: {
|
|
59
138
|
totalBudgetUsd: number;
|
|
60
139
|
sliceMaxCostUsd: number;
|