@jinn-network/client 0.1.2 → 0.1.3-canary.24b69ea4
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 +20 -0
- package/CONTRIBUTING.md +9 -2
- package/README.md +67 -47
- package/deployments/deployment-jinn-mvi-l1-sepolia-fast.json +36 -0
- package/deployments/deployment-jinn-mvi-l1-sepolia.json +36 -0
- package/deployments/deployment-jinn-mvi-l2-baseSepolia.json +12 -0
- package/deployments/deployment-phase1b-mech-baseSepolia-fast.json +3 -3
- package/deployments/deployment-stolas-l2-baseSepolia-fast.json +1 -1
- package/deployments/deployment-task-coordinator-router-v3-baseSepolia-fast.json +38 -0
- package/dist/adapters/adapter.d.ts +19 -8
- package/dist/adapters/local/adapter.d.ts +10 -9
- package/dist/adapters/local/adapter.js +52 -79
- package/dist/adapters/local/adapter.js.map +1 -1
- package/dist/adapters/mech/adapter.d.ts +37 -15
- package/dist/adapters/mech/adapter.js +557 -364
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +80 -20
- package/dist/adapters/mech/contracts.js +372 -100
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/ipfs.d.ts +66 -12
- package/dist/adapters/mech/ipfs.js +165 -30
- package/dist/adapters/mech/ipfs.js.map +1 -1
- package/dist/adapters/mech/safe-revert.d.ts +40 -0
- package/dist/adapters/mech/safe-revert.js +261 -0
- package/dist/adapters/mech/safe-revert.js.map +1 -0
- package/dist/adapters/mech/safe.js +48 -22
- package/dist/adapters/mech/safe.js.map +1 -1
- package/dist/adapters/mech/task-subgraph.d.ts +23 -0
- package/dist/adapters/mech/task-subgraph.js +157 -0
- package/dist/adapters/mech/task-subgraph.js.map +1 -0
- package/dist/adapters/mech/types.d.ts +256 -84
- package/dist/adapters/mech/types.js +125 -50
- package/dist/adapters/mech/types.js.map +1 -1
- package/dist/agent/agent-ws.d.ts +57 -0
- package/dist/agent/agent-ws.js +301 -0
- package/dist/agent/agent-ws.js.map +1 -0
- package/dist/agent/auto-mode-detect.d.ts +6 -0
- package/dist/agent/auto-mode-detect.js +44 -0
- package/dist/agent/auto-mode-detect.js.map +1 -0
- package/dist/agent/operator-claude.d.ts +22 -0
- package/dist/agent/operator-claude.js +176 -0
- package/dist/agent/operator-claude.js.map +1 -0
- package/dist/api/admin-endpoint.d.ts +12 -0
- package/dist/api/admin-endpoint.js +71 -0
- package/dist/api/admin-endpoint.js.map +1 -0
- package/dist/api/agent-binding-endpoint.d.ts +26 -0
- package/dist/api/agent-binding-endpoint.js +28 -0
- package/dist/api/agent-binding-endpoint.js.map +1 -0
- package/dist/api/bootstrap-endpoint.d.ts +25 -0
- package/dist/api/bootstrap-endpoint.js +104 -0
- package/dist/api/bootstrap-endpoint.js.map +1 -0
- package/dist/api/captures.d.ts +22 -0
- package/dist/api/captures.js +88 -0
- package/dist/api/captures.js.map +1 -0
- package/dist/api/events-endpoint.d.ts +9 -0
- package/dist/api/events-endpoint.js +46 -0
- package/dist/api/events-endpoint.js.map +1 -0
- package/dist/api/fleet-build.d.ts +1 -1
- package/dist/api/fleet-build.js +17 -8
- package/dist/api/fleet-build.js.map +1 -1
- package/dist/api/gather-status.d.ts +16 -1
- package/dist/api/gather-status.js +194 -3
- package/dist/api/gather-status.js.map +1 -1
- package/dist/api/handshake.d.ts +17 -0
- package/dist/api/handshake.js +28 -0
- package/dist/api/handshake.js.map +1 -0
- package/dist/api/harness-status-endpoint.d.ts +20 -0
- package/dist/api/harness-status-endpoint.js +13 -0
- package/dist/api/harness-status-endpoint.js.map +1 -0
- package/dist/api/history-build.d.ts +2 -2
- package/dist/api/history-build.js +3 -3
- package/dist/api/history-build.js.map +1 -1
- package/dist/api/launcher-endpoints.d.ts +43 -0
- package/dist/api/launcher-endpoints.js +50 -0
- package/dist/api/launcher-endpoints.js.map +1 -0
- package/dist/api/launcher-status.d.ts +93 -0
- package/dist/api/launcher-status.js +84 -0
- package/dist/api/launcher-status.js.map +1 -0
- package/dist/api/launcher-tasks.d.ts +76 -0
- package/dist/api/launcher-tasks.js +127 -0
- package/dist/api/launcher-tasks.js.map +1 -0
- package/dist/api/leaderboard-api.d.ts +20 -0
- package/dist/api/leaderboard-api.js +18 -0
- package/dist/api/leaderboard-api.js.map +1 -0
- package/dist/api/operator-artifacts-endpoint.d.ts +19 -0
- package/dist/api/operator-artifacts-endpoint.js +271 -0
- package/dist/api/operator-artifacts-endpoint.js.map +1 -0
- package/dist/api/peers.js +21 -6
- package/dist/api/peers.js.map +1 -1
- package/dist/api/portfolio-v0-build.d.ts +16 -10
- package/dist/api/portfolio-v0-build.js +36 -31
- package/dist/api/portfolio-v0-build.js.map +1 -1
- package/dist/api/portfolio-v0-doctor.js +1 -1
- package/dist/api/portfolio-v0-doctor.js.map +1 -1
- package/dist/api/prediction-v1-build.d.ts +65 -0
- package/dist/api/prediction-v1-build.js +73 -0
- package/dist/api/prediction-v1-build.js.map +1 -0
- package/dist/api/rewards-build.js +3 -8
- package/dist/api/rewards-build.js.map +1 -1
- package/dist/api/server.d.ts +106 -1
- package/dist/api/server.js +396 -17
- package/dist/api/server.js.map +1 -1
- package/dist/api/setup-endpoints.d.ts +62 -0
- package/dist/api/setup-endpoints.js +752 -0
- package/dist/api/setup-endpoints.js.map +1 -0
- package/dist/api/solvernets-catalog-build.d.ts +47 -0
- package/dist/api/solvernets-catalog-build.js +19 -0
- package/dist/api/solvernets-catalog-build.js.map +1 -0
- package/dist/api/solvernets-endpoint.d.ts +15 -0
- package/dist/api/solvernets-endpoint.js +5 -0
- package/dist/api/solvernets-endpoint.js.map +1 -0
- package/dist/api/solvernets-endpoints.d.ts +104 -0
- package/dist/api/solvernets-endpoints.js +1121 -0
- package/dist/api/solvernets-endpoints.js.map +1 -0
- package/dist/api/status-build.d.ts +26 -2
- package/dist/api/status-build.js +46 -9
- package/dist/api/status-build.js.map +1 -1
- package/dist/api/status-rollup-build.d.ts +46 -1
- package/dist/api/status-rollup-build.js +174 -8
- package/dist/api/status-rollup-build.js.map +1 -1
- package/dist/api/stop-hook.d.ts +36 -0
- package/dist/api/stop-hook.js +77 -0
- package/dist/api/stop-hook.js.map +1 -0
- package/dist/api/task-runs-build.d.ts +27 -0
- package/dist/api/task-runs-build.js +46 -0
- package/dist/api/task-runs-build.js.map +1 -0
- package/dist/api/ui-token.d.ts +5 -0
- package/dist/api/ui-token.js +36 -0
- package/dist/api/ui-token.js.map +1 -0
- package/dist/bin/jinn-stop-hook.d.ts +9 -0
- package/dist/bin/jinn-stop-hook.js +52 -0
- package/dist/bin/jinn-stop-hook.js.map +1 -0
- package/dist/build-info.d.ts +32 -0
- package/dist/build-info.js +69 -0
- package/dist/build-info.js.map +1 -0
- package/dist/build-info.json +6 -0
- package/dist/build-meta.json +1 -1
- package/dist/captures/dedup.d.ts +27 -0
- package/dist/captures/dedup.js +48 -0
- package/dist/captures/dedup.js.map +1 -0
- package/dist/captures/index.d.ts +4 -0
- package/dist/captures/index.js +5 -0
- package/dist/captures/index.js.map +1 -0
- package/dist/captures/live-publisher.d.ts +33 -0
- package/dist/captures/live-publisher.js +101 -0
- package/dist/captures/live-publisher.js.map +1 -0
- package/dist/captures/publish.d.ts +83 -0
- package/dist/captures/publish.js +212 -0
- package/dist/captures/publish.js.map +1 -0
- package/dist/captures/rate-limit.d.ts +39 -0
- package/dist/captures/rate-limit.js +79 -0
- package/dist/captures/rate-limit.js.map +1 -0
- package/dist/cli/command.d.ts +9 -0
- package/dist/cli/commands/auth.js +6 -3
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/balance.d.ts +7 -0
- package/dist/cli/commands/balance.js +38 -32
- package/dist/cli/commands/balance.js.map +1 -1
- package/dist/cli/commands/bootstrap.d.ts +13 -1
- package/dist/cli/commands/bootstrap.js +150 -133
- package/dist/cli/commands/bootstrap.js.map +1 -1
- package/dist/cli/commands/capture.d.ts +33 -0
- package/dist/cli/commands/capture.js +345 -0
- package/dist/cli/commands/capture.js.map +1 -0
- package/dist/cli/commands/checkpoint.d.ts +85 -0
- package/dist/cli/commands/checkpoint.js +75 -0
- package/dist/cli/commands/checkpoint.js.map +1 -0
- package/dist/cli/commands/claim-rewards.js +14 -2
- package/dist/cli/commands/claim-rewards.js.map +1 -1
- package/dist/cli/commands/conformance.d.ts +12 -0
- package/dist/cli/commands/conformance.js +140 -0
- package/dist/cli/commands/conformance.js.map +1 -0
- package/dist/cli/commands/create.d.ts +22 -0
- package/dist/cli/commands/create.js +226 -0
- package/dist/cli/commands/create.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +49 -1
- package/dist/cli/commands/doctor.js +162 -134
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/fleet-scale.d.ts +19 -1
- package/dist/cli/commands/fleet-scale.js +378 -361
- package/dist/cli/commands/fleet-scale.js.map +1 -1
- package/dist/cli/commands/fleet.d.ts +7 -0
- package/dist/cli/commands/fleet.js +39 -33
- package/dist/cli/commands/fleet.js.map +1 -1
- package/dist/cli/commands/fund-requirements.d.ts +14 -1
- package/dist/cli/commands/fund-requirements.js +182 -174
- package/dist/cli/commands/fund-requirements.js.map +1 -1
- package/dist/cli/commands/harnesses.d.ts +38 -0
- package/dist/cli/commands/harnesses.js +376 -0
- package/dist/cli/commands/harnesses.js.map +1 -0
- package/dist/cli/commands/history.d.ts +10 -1
- package/dist/cli/commands/history.js +68 -59
- package/dist/cli/commands/history.js.map +1 -1
- package/dist/cli/commands/init.js +4 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/integrations.d.ts +13 -0
- package/dist/cli/commands/integrations.js +1010 -0
- package/dist/cli/commands/integrations.js.map +1 -0
- package/dist/cli/commands/logs.d.ts +6 -1
- package/dist/cli/commands/logs.js +77 -70
- package/dist/cli/commands/logs.js.map +1 -1
- package/dist/cli/commands/migrate-agent-id.d.ts +26 -0
- package/dist/cli/commands/migrate-agent-id.js +164 -0
- package/dist/cli/commands/migrate-agent-id.js.map +1 -0
- package/dist/cli/commands/prediction-scoreboard.d.ts +10 -0
- package/dist/cli/commands/prediction-scoreboard.js +136 -0
- package/dist/cli/commands/prediction-scoreboard.js.map +1 -0
- package/dist/cli/commands/quickstart.d.ts +51 -1
- package/dist/cli/commands/quickstart.js +514 -296
- package/dist/cli/commands/quickstart.js.map +1 -1
- package/dist/cli/commands/rewards.d.ts +7 -0
- package/dist/cli/commands/rewards.js +46 -40
- package/dist/cli/commands/rewards.js.map +1 -1
- package/dist/cli/commands/run.d.ts +14 -1
- package/dist/cli/commands/run.js +243 -91
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/solver-nets.js +231 -0
- package/dist/cli/commands/solver-nets.js.map +1 -0
- package/dist/cli/commands/solver-plugins.d.ts +9 -0
- package/dist/cli/commands/solver-plugins.js +186 -0
- package/dist/cli/commands/solver-plugins.js.map +1 -0
- package/dist/cli/commands/status.d.ts +13 -0
- package/dist/cli/commands/status.js +105 -34
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/stop.js +87 -14
- package/dist/cli/commands/stop.js.map +1 -1
- package/dist/cli/commands/tasks.js +405 -0
- package/dist/cli/commands/tasks.js.map +1 -0
- package/dist/cli/commands/ui.d.ts +3 -0
- package/dist/cli/commands/ui.js +45 -0
- package/dist/cli/commands/ui.js.map +1 -0
- package/dist/cli/commands/update.d.ts +12 -0
- package/dist/cli/commands/update.js +321 -91
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/commands/version.js +3 -2
- package/dist/cli/commands/version.js.map +1 -1
- package/dist/cli/commands/withdraw.d.ts +21 -1
- package/dist/cli/commands/withdraw.js +175 -159
- package/dist/cli/commands/withdraw.js.map +1 -1
- package/dist/cli/deployment-digest.js +0 -5
- package/dist/cli/deployment-digest.js.map +1 -1
- package/dist/cli/execution-context.d.ts +1 -1
- package/dist/cli/execution-context.js +4 -4
- package/dist/cli/execution-context.js.map +1 -1
- package/dist/cli/help.js +8 -1
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.js +28 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/introspection-context.js +0 -1
- package/dist/cli/introspection-context.js.map +1 -1
- package/dist/cli/open-browser.d.ts +1 -0
- package/dist/cli/open-browser.js +18 -0
- package/dist/cli/open-browser.js.map +1 -0
- package/dist/cli/password.d.ts +3 -3
- package/dist/cli/password.js +6 -6
- package/dist/cli/password.js.map +1 -1
- package/dist/cli/task-native-readiness.d.ts +27 -0
- package/dist/cli/task-native-readiness.js +170 -0
- package/dist/cli/task-native-readiness.js.map +1 -0
- package/dist/config.d.ts +1897 -60
- package/dist/config.js +602 -33
- package/dist/config.js.map +1 -1
- package/dist/conformance/checks/artifacts.d.ts +37 -0
- package/dist/conformance/checks/artifacts.js +110 -0
- package/dist/conformance/checks/artifacts.js.map +1 -0
- package/dist/conformance/checks/envelope-schema.d.ts +17 -0
- package/dist/conformance/checks/envelope-schema.js +36 -0
- package/dist/conformance/checks/envelope-schema.js.map +1 -0
- package/dist/conformance/checks/hash-signature.d.ts +26 -0
- package/dist/conformance/checks/hash-signature.js +70 -0
- package/dist/conformance/checks/hash-signature.js.map +1 -0
- package/dist/conformance/checks/payload.d.ts +19 -0
- package/dist/conformance/checks/payload.js +52 -0
- package/dist/conformance/checks/payload.js.map +1 -0
- package/dist/conformance/checks/secret-scrub.d.ts +33 -0
- package/dist/conformance/checks/secret-scrub.js +118 -0
- package/dist/conformance/checks/secret-scrub.js.map +1 -0
- package/dist/conformance/checks/source-runtime.d.ts +43 -0
- package/dist/conformance/checks/source-runtime.js +68 -0
- package/dist/conformance/checks/source-runtime.js.map +1 -0
- package/dist/conformance/checks/source-static.d.ts +61 -0
- package/dist/conformance/checks/source-static.js +311 -0
- package/dist/conformance/checks/source-static.js.map +1 -0
- package/dist/conformance/checks/trajectory-chain.d.ts +18 -0
- package/dist/conformance/checks/trajectory-chain.js +51 -0
- package/dist/conformance/checks/trajectory-chain.js.map +1 -0
- package/dist/conformance/checks/trajectory-profile.d.ts +17 -0
- package/dist/conformance/checks/trajectory-profile.js +51 -0
- package/dist/conformance/checks/trajectory-profile.js.map +1 -0
- package/dist/conformance/checks/trajectory-schema.d.ts +20 -0
- package/dist/conformance/checks/trajectory-schema.js +40 -0
- package/dist/conformance/checks/trajectory-schema.js.map +1 -0
- package/dist/conformance/checks/verdict.d.ts +44 -0
- package/dist/conformance/checks/verdict.js +122 -0
- package/dist/conformance/checks/verdict.js.map +1 -0
- package/dist/conformance/harness.d.ts +32 -0
- package/dist/conformance/harness.js +227 -0
- package/dist/conformance/harness.js.map +1 -0
- package/dist/conformance/types.d.ts +88 -0
- package/dist/conformance/types.js +31 -0
- package/dist/conformance/types.js.map +1 -0
- package/dist/corpus/acquire.d.ts +42 -0
- package/dist/corpus/acquire.js +213 -0
- package/dist/corpus/acquire.js.map +1 -0
- package/dist/corpus/cache.d.ts +14 -0
- package/dist/corpus/cache.js +18 -0
- package/dist/corpus/cache.js.map +1 -0
- package/dist/corpus/envelope-projection.d.ts +12 -0
- package/dist/corpus/envelope-projection.js +110 -0
- package/dist/corpus/envelope-projection.js.map +1 -0
- package/dist/corpus/fetch.d.ts +9 -0
- package/dist/corpus/fetch.js +24 -0
- package/dist/corpus/fetch.js.map +1 -0
- package/dist/corpus/index.d.ts +19 -0
- package/dist/corpus/index.js +87 -0
- package/dist/corpus/index.js.map +1 -0
- package/dist/corpus/prediction-brier-scoreboard-report.d.ts +17 -0
- package/dist/corpus/prediction-brier-scoreboard-report.js +148 -0
- package/dist/corpus/prediction-brier-scoreboard-report.js.map +1 -0
- package/dist/corpus/prediction-brier-scoreboard.d.ts +56 -0
- package/dist/corpus/prediction-brier-scoreboard.js +269 -0
- package/dist/corpus/prediction-brier-scoreboard.js.map +1 -0
- package/dist/corpus/prediction-scoreable-verdicts.d.ts +4 -0
- package/dist/corpus/prediction-scoreable-verdicts.js +23 -0
- package/dist/corpus/prediction-scoreable-verdicts.js.map +1 -0
- package/dist/corpus/query.d.ts +17 -0
- package/dist/corpus/query.js +113 -0
- package/dist/corpus/query.js.map +1 -0
- package/dist/corpus/route-resolver.d.ts +16 -0
- package/dist/corpus/route-resolver.js +20 -0
- package/dist/corpus/route-resolver.js.map +1 -0
- package/dist/corpus/types.d.ts +151 -0
- package/dist/corpus/types.js +50 -0
- package/dist/corpus/types.js.map +1 -0
- package/dist/daemon/balance-topup-loop.js +2 -1
- package/dist/daemon/balance-topup-loop.js.map +1 -1
- package/dist/daemon/creator.d.ts +7 -7
- package/dist/daemon/creator.js +11 -14
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +83 -31
- package/dist/daemon/daemon.js +206 -67
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/delivery-watcher.js +50 -4
- package/dist/daemon/delivery-watcher.js.map +1 -1
- package/dist/daemon/freeze-fence.d.ts +42 -0
- package/dist/daemon/freeze-fence.js +71 -0
- package/dist/daemon/freeze-fence.js.map +1 -0
- package/dist/daemon/jinn-claim-loop-canonical.d.ts +207 -0
- package/dist/daemon/jinn-claim-loop-canonical.js +296 -0
- package/dist/daemon/jinn-claim-loop-canonical.js.map +1 -0
- package/dist/daemon/jinn-claim-loop-mock.d.ts +61 -0
- package/dist/daemon/jinn-claim-loop-mock.js +122 -0
- package/dist/daemon/jinn-claim-loop-mock.js.map +1 -0
- package/dist/daemon/jinn-claim-loop.d.ts +123 -0
- package/dist/daemon/jinn-claim-loop.js +256 -0
- package/dist/daemon/jinn-claim-loop.js.map +1 -0
- package/dist/daemon/reward-claim-loop.d.ts +2 -0
- package/dist/daemon/reward-claim-loop.js +32 -27
- package/dist/daemon/reward-claim-loop.js.map +1 -1
- package/dist/dashboard/assets/index-DBPsa50k.js +76 -0
- package/dist/dashboard/assets/index-D_NMfDfV.css +32 -0
- package/dist/dashboard/index.html +18 -74
- package/dist/earning/agent-wallet-binding.d.ts +133 -0
- package/dist/earning/agent-wallet-binding.js +202 -0
- package/dist/earning/agent-wallet-binding.js.map +1 -0
- package/dist/earning/bootstrap.d.ts +88 -1
- package/dist/earning/bootstrap.js +409 -56
- package/dist/earning/bootstrap.js.map +1 -1
- package/dist/earning/contracts.d.ts +328 -6
- package/dist/earning/contracts.js +295 -14
- package/dist/earning/contracts.js.map +1 -1
- package/dist/earning/evidence-simhash.d.ts +1 -1
- package/dist/earning/faucet.d.ts +31 -0
- package/dist/earning/faucet.js +37 -0
- package/dist/earning/faucet.js.map +1 -1
- package/dist/earning/funding-plan.d.ts +89 -0
- package/dist/earning/funding-plan.js +202 -0
- package/dist/earning/funding-plan.js.map +1 -0
- package/dist/earning/migrate-agent-id.d.ts +129 -0
- package/dist/earning/migrate-agent-id.js +256 -0
- package/dist/earning/migrate-agent-id.js.map +1 -0
- package/dist/earning/orphan-sweep.d.ts +14 -0
- package/dist/earning/orphan-sweep.js +63 -2
- package/dist/earning/orphan-sweep.js.map +1 -1
- package/dist/earning/reconcile.d.ts +2 -0
- package/dist/earning/reconcile.js +30 -0
- package/dist/earning/reconcile.js.map +1 -1
- package/dist/earning/safe-adapter.js +45 -3
- package/dist/earning/safe-adapter.js.map +1 -1
- package/dist/earning/stolas-claim.d.ts +86 -6
- package/dist/earning/stolas-claim.js +123 -9
- package/dist/earning/stolas-claim.js.map +1 -1
- package/dist/earning/store.d.ts +47 -0
- package/dist/earning/store.js +113 -1
- package/dist/earning/store.js.map +1 -1
- package/dist/earning/testnet-setup-migration.d.ts +32 -0
- package/dist/earning/testnet-setup-migration.js +214 -0
- package/dist/earning/testnet-setup-migration.js.map +1 -0
- package/dist/earning/types.d.ts +57 -9
- package/dist/earning/types.js +51 -2
- package/dist/earning/types.js.map +1 -1
- package/dist/earning/viem-clients.d.ts +20 -0
- package/dist/earning/viem-clients.js +32 -1
- package/dist/earning/viem-clients.js.map +1 -1
- package/dist/erc8004/abis.d.ts +423 -0
- package/dist/erc8004/abis.js +265 -0
- package/dist/erc8004/abis.js.map +1 -0
- package/dist/erc8004/addresses.d.ts +40 -0
- package/dist/erc8004/addresses.js +64 -0
- package/dist/erc8004/addresses.js.map +1 -0
- package/dist/erc8004/identity.d.ts +273 -0
- package/dist/erc8004/identity.js +405 -0
- package/dist/erc8004/identity.js.map +1 -0
- package/dist/erc8004/index.d.ts +13 -0
- package/dist/erc8004/index.js +20 -0
- package/dist/erc8004/index.js.map +1 -0
- package/dist/erc8004/reputation.d.ts +349 -0
- package/dist/erc8004/reputation.js +464 -0
- package/dist/erc8004/reputation.js.map +1 -0
- package/dist/erc8004/subgraph.d.ts +46 -0
- package/dist/erc8004/subgraph.js +37 -0
- package/dist/erc8004/subgraph.js.map +1 -0
- package/dist/erc8004/validation.d.ts +145 -0
- package/dist/erc8004/validation.js +219 -0
- package/dist/erc8004/validation.js.map +1 -0
- package/dist/errors/persisted-bootstrap-error.d.ts +4 -0
- package/dist/errors/persisted-bootstrap-error.js +50 -0
- package/dist/errors/persisted-bootstrap-error.js.map +1 -0
- package/dist/events/emitter.d.ts +12 -0
- package/dist/events/emitter.js +23 -0
- package/dist/events/emitter.js.map +1 -0
- package/dist/events/ring-buffer.d.ts +25 -0
- package/dist/events/ring-buffer.js +46 -0
- package/dist/events/ring-buffer.js.map +1 -0
- package/dist/events/types.d.ts +42 -0
- package/dist/events/types.js +28 -0
- package/dist/events/types.js.map +1 -0
- package/dist/harnesses/capability/index.d.ts +82 -0
- package/dist/harnesses/capability/index.js +12 -0
- package/dist/harnesses/capability/index.js.map +1 -0
- package/dist/harnesses/capability/scoped-rpc.d.ts +12 -0
- package/dist/harnesses/capability/scoped-rpc.js +34 -0
- package/dist/harnesses/capability/scoped-rpc.js.map +1 -0
- package/dist/harnesses/capability/scoped-secrets.d.ts +8 -0
- package/dist/harnesses/capability/scoped-secrets.js +10 -0
- package/dist/harnesses/capability/scoped-secrets.js.map +1 -0
- package/dist/harnesses/capability/scoped-signer.d.ts +46 -0
- package/dist/harnesses/capability/scoped-signer.js +73 -0
- package/dist/harnesses/capability/scoped-signer.js.map +1 -0
- package/dist/harnesses/engine/artifact-scrub.d.ts +12 -0
- package/dist/harnesses/engine/artifact-scrub.js +104 -0
- package/dist/harnesses/engine/artifact-scrub.js.map +1 -0
- package/dist/harnesses/engine/canonical-json.d.ts +1 -0
- package/dist/harnesses/engine/canonical-json.js +66 -0
- package/dist/harnesses/engine/canonical-json.js.map +1 -0
- package/dist/harnesses/engine/delivery.d.ts +58 -0
- package/dist/harnesses/engine/delivery.js +67 -0
- package/dist/harnesses/engine/delivery.js.map +1 -0
- package/dist/harnesses/engine/engine.d.ts +519 -0
- package/dist/harnesses/engine/engine.js +1588 -0
- package/dist/harnesses/engine/engine.js.map +1 -0
- package/dist/harnesses/engine/envelope-assembly.d.ts +73 -0
- package/dist/harnesses/engine/envelope-assembly.js +60 -0
- package/dist/harnesses/engine/envelope-assembly.js.map +1 -0
- package/dist/harnesses/engine/packaging.d.ts +99 -0
- package/dist/harnesses/engine/packaging.js +424 -0
- package/dist/harnesses/engine/packaging.js.map +1 -0
- package/dist/harnesses/engine/persistence.d.ts +198 -0
- package/dist/harnesses/engine/persistence.js +443 -0
- package/dist/harnesses/engine/persistence.js.map +1 -0
- package/dist/harnesses/engine/recovery.d.ts +22 -0
- package/dist/harnesses/engine/recovery.js +24 -0
- package/dist/harnesses/engine/recovery.js.map +1 -0
- package/dist/harnesses/engine/registry.d.ts +55 -0
- package/dist/harnesses/engine/registry.js +66 -0
- package/dist/harnesses/engine/registry.js.map +1 -0
- package/dist/harnesses/engine/signing.d.ts +30 -0
- package/dist/harnesses/engine/signing.js +39 -0
- package/dist/harnesses/engine/signing.js.map +1 -0
- package/dist/harnesses/engine/state.d.ts +42 -0
- package/dist/harnesses/engine/state.js +87 -0
- package/dist/harnesses/engine/state.js.map +1 -0
- package/dist/harnesses/engine/validate-manifest.d.ts +23 -0
- package/dist/harnesses/engine/validate-manifest.js +63 -0
- package/dist/harnesses/engine/validate-manifest.js.map +1 -0
- package/dist/harnesses/engine/verification-stub.d.ts +18 -0
- package/dist/harnesses/engine/verification-stub.js +18 -0
- package/dist/harnesses/engine/verification-stub.js.map +1 -0
- package/dist/harnesses/external-impls/index.d.ts +3 -0
- package/dist/harnesses/external-impls/index.js +2 -0
- package/dist/harnesses/external-impls/index.js.map +1 -0
- package/dist/harnesses/external-impls/loader.d.ts +50 -0
- package/dist/harnesses/external-impls/loader.js +139 -0
- package/dist/harnesses/external-impls/loader.js.map +1 -0
- package/dist/harnesses/external-impls/package-hash.d.ts +26 -0
- package/dist/harnesses/external-impls/package-hash.js +102 -0
- package/dist/harnesses/external-impls/package-hash.js.map +1 -0
- package/dist/harnesses/external-impls/types.d.ts +42 -0
- package/dist/harnesses/external-impls/types.js +10 -0
- package/dist/harnesses/external-impls/types.js.map +1 -0
- package/dist/harnesses/freeze.d.ts +34 -0
- package/dist/harnesses/freeze.js +60 -0
- package/dist/harnesses/freeze.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.d.ts +57 -0
- package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.js +239 -0
- package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/adapters/codex-code.d.ts +31 -0
- package/dist/harnesses/impls/claude-code-learner/adapters/codex-code.js +257 -0
- package/dist/harnesses/impls/claude-code-learner/adapters/codex-code.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/adapters/codex-workspace.d.ts +21 -0
- package/dist/harnesses/impls/claude-code-learner/adapters/codex-workspace.js +193 -0
- package/dist/harnesses/impls/claude-code-learner/adapters/codex-workspace.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/harness.d.ts +22 -0
- package/dist/harnesses/impls/claude-code-learner/harness.js +62 -0
- package/dist/harnesses/impls/claude-code-learner/harness.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/harvest.d.ts +20 -0
- package/dist/harnesses/impls/claude-code-learner/harvest.js +510 -0
- package/dist/harnesses/impls/claude-code-learner/harvest.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/index.d.ts +18 -0
- package/dist/harnesses/impls/claude-code-learner/index.js +15 -0
- package/dist/harnesses/impls/claude-code-learner/index.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/plugin-path.d.ts +14 -0
- package/dist/harnesses/impls/claude-code-learner/plugin-path.js +30 -0
- package/dist/harnesses/impls/claude-code-learner/plugin-path.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.d.ts +50 -0
- package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.js +192 -0
- package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/test-utils/noop-adapter.d.ts +22 -0
- package/dist/harnesses/impls/claude-code-learner/test-utils/noop-adapter.js +35 -0
- package/dist/harnesses/impls/claude-code-learner/test-utils/noop-adapter.js.map +1 -0
- package/dist/harnesses/impls/claude-code-learner/types.d.ts +114 -0
- package/dist/harnesses/impls/claude-code-learner/types.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/api-wallet.d.ts +64 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/index.d.ts +106 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/index.js +723 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/index.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +104 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/session-orchestrator.js +264 -0
- package/dist/harnesses/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction/index.d.ts +44 -0
- package/dist/harnesses/impls/claude-mcp-prediction/index.js +250 -0
- package/dist/harnesses/impls/claude-mcp-prediction/index.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction/mcp-tools.js +135 -0
- package/dist/harnesses/impls/claude-mcp-prediction/mcp-tools.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction/prompt.d.ts +8 -0
- package/dist/harnesses/impls/claude-mcp-prediction/prompt.js +54 -0
- package/dist/harnesses/impls/claude-mcp-prediction/prompt.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.d.ts +43 -0
- package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.js +21 -0
- package/dist/harnesses/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction/types.d.ts +84 -0
- package/dist/harnesses/impls/claude-mcp-prediction/types.js +6 -0
- package/dist/harnesses/impls/claude-mcp-prediction/types.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/index.d.ts +36 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/index.js +241 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/index.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/mcp-tools.js +136 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/mcp-tools.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/prompt.d.ts +7 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/prompt.js +46 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/prompt.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.d.ts +37 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.js +19 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/types.d.ts +64 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/types.js +6 -0
- package/dist/harnesses/impls/claude-mcp-prediction-apy/types.js.map +1 -0
- package/dist/harnesses/impls/claude-mcp-shared/single-session-orchestrator.d.ts +84 -0
- package/dist/harnesses/impls/claude-mcp-shared/single-session-orchestrator.js +206 -0
- package/dist/harnesses/impls/claude-mcp-shared/single-session-orchestrator.js.map +1 -0
- package/dist/harnesses/impls/evaluation-context.d.ts +23 -0
- package/dist/harnesses/impls/evaluation-context.js +25 -0
- package/dist/harnesses/impls/evaluation-context.js.map +1 -0
- package/dist/harnesses/impls/index.d.ts +84 -0
- package/dist/harnesses/impls/index.js +136 -0
- package/dist/harnesses/impls/index.js.map +1 -0
- package/dist/harnesses/impls/legacy-claude/index.d.ts +66 -0
- package/dist/harnesses/impls/legacy-claude/index.js +168 -0
- package/dist/harnesses/impls/legacy-claude/index.js.map +1 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +68 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/canonical-metrics.js +117 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/consistency.d.ts +78 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/consistency.js +274 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +23 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/eligibility.js +49 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/integrity.d.ts +25 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/integrity.js +44 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/spec.d.ts +17 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/spec.js +43 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/index.d.ts +44 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/index.js +569 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/index.js.map +1 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/score.js.map +1 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/types.d.ts +34 -0
- package/dist/harnesses/impls/portfolio-v0-evaluator/types.js.map +1 -0
- package/dist/harnesses/impls/prediction-apy-v0-baseline/index.d.ts +42 -0
- package/dist/harnesses/impls/prediction-apy-v0-baseline/index.js +114 -0
- package/dist/harnesses/impls/prediction-apy-v0-baseline/index.js.map +1 -0
- package/dist/harnesses/impls/prediction-apy-v0-baseline/strategy.js.map +1 -0
- package/dist/harnesses/impls/prediction-apy-v0-baseline/types.js.map +1 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +6 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/canonical-metrics.js +11 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +1 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.d.ts +42 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.js +346 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +16 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/parse-submission.js +22 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/parse-submission.js.map +1 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/score.js.map +1 -0
- package/dist/harnesses/impls/prediction-apy-v0-evaluator/types.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-baseline/index.d.ts +33 -0
- package/dist/harnesses/impls/prediction-v0-baseline/index.js +109 -0
- package/dist/harnesses/impls/prediction-v0-baseline/index.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-baseline/strategy.d.ts +8 -0
- package/dist/harnesses/impls/prediction-v0-baseline/strategy.js +41 -0
- package/dist/harnesses/impls/prediction-v0-baseline/strategy.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-baseline/types.d.ts +7 -0
- package/dist/harnesses/impls/prediction-v0-baseline/types.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/canonical-metrics.d.ts +20 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/checks/availability.d.ts +9 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/checks/eligibility.d.ts +3 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/checks/integrity.d.ts +15 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/checks/integrity.js +111 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/checks/spec.d.ts +5 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/index.d.ts +36 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/index.js +342 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/index.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/score.js.map +1 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/types.js +2 -0
- package/dist/harnesses/impls/prediction-v0-evaluator/types.js.map +1 -0
- package/dist/harnesses/impls/prediction-v1-baseline/index.d.ts +31 -0
- package/dist/harnesses/impls/prediction-v1-baseline/index.js +79 -0
- package/dist/harnesses/impls/prediction-v1-baseline/index.js.map +1 -0
- package/dist/harnesses/impls/prediction-v1-evaluator/index.d.ts +32 -0
- package/dist/harnesses/impls/prediction-v1-evaluator/index.js +219 -0
- package/dist/harnesses/impls/prediction-v1-evaluator/index.js.map +1 -0
- package/dist/harnesses/impls/session-derived-evaluator/index.d.ts +4 -0
- package/dist/harnesses/impls/session-derived-evaluator/index.js +5 -0
- package/dist/harnesses/impls/session-derived-evaluator/index.js.map +1 -0
- package/dist/harnesses/impls/session-derived-evaluator/llm-judge.d.ts +16 -0
- package/dist/harnesses/impls/session-derived-evaluator/llm-judge.js +16 -0
- package/dist/harnesses/impls/session-derived-evaluator/llm-judge.js.map +1 -0
- package/dist/harnesses/impls/session-derived-evaluator/signals.d.ts +13 -0
- package/dist/harnesses/impls/session-derived-evaluator/signals.js +15 -0
- package/dist/harnesses/impls/session-derived-evaluator/signals.js.map +1 -0
- package/dist/harnesses/impls/session-derived-evaluator/structural-similarity.d.ts +7 -0
- package/dist/harnesses/impls/session-derived-evaluator/structural-similarity.js +28 -0
- package/dist/harnesses/impls/session-derived-evaluator/structural-similarity.js.map +1 -0
- package/dist/harnesses/impls/session-derived-evaluator/test-suite-rerun.d.ts +15 -0
- package/dist/harnesses/impls/session-derived-evaluator/test-suite-rerun.js +17 -0
- package/dist/harnesses/impls/session-derived-evaluator/test-suite-rerun.js.map +1 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.d.ts +20 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +107 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.d.ts +74 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js +288 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js.map +1 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.d.ts +33 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js +96 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js.map +1 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.d.ts +61 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js +42 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js.map +1 -0
- package/dist/harnesses/manifest/index.d.ts +3 -0
- package/dist/harnesses/manifest/index.js +3 -0
- package/dist/harnesses/manifest/index.js.map +1 -0
- package/dist/harnesses/manifest/load.d.ts +7 -0
- package/dist/harnesses/manifest/load.js +49 -0
- package/dist/harnesses/manifest/load.js.map +1 -0
- package/dist/harnesses/manifest/types.d.ts +75 -0
- package/dist/harnesses/manifest/types.js +8 -0
- package/dist/harnesses/manifest/types.js.map +1 -0
- package/dist/harnesses/manifest/verify.d.ts +15 -0
- package/dist/harnesses/manifest/verify.js +53 -0
- package/dist/harnesses/manifest/verify.js.map +1 -0
- package/dist/harnesses/mode-state.d.ts +7 -0
- package/dist/harnesses/mode-state.js +43 -0
- package/dist/harnesses/mode-state.js.map +1 -0
- package/dist/harnesses/names.d.ts +6 -0
- package/dist/harnesses/names.js +24 -0
- package/dist/harnesses/names.js.map +1 -0
- package/dist/harnesses/types.d.ts +276 -0
- package/dist/harnesses/types.js +28 -0
- package/dist/harnesses/types.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/main.d.ts +17 -2
- package/dist/main.js +1593 -147
- package/dist/main.js.map +1 -1
- package/dist/mcp/acquire-artifact.d.ts +41 -0
- package/dist/mcp/acquire-artifact.js +168 -0
- package/dist/mcp/acquire-artifact.js.map +1 -0
- package/dist/mcp/operator-server.d.ts +21 -4
- package/dist/mcp/operator-server.js +505 -30
- package/dist/mcp/operator-server.js.map +1 -1
- package/dist/mcp/search-records.d.ts +94 -0
- package/dist/mcp/search-records.js +396 -0
- package/dist/mcp/search-records.js.map +1 -0
- package/dist/mcp/server.d.ts +4 -4
- package/dist/mcp/server.js +240 -61
- package/dist/mcp/server.js.map +1 -1
- package/dist/observability/emit-event.d.ts +2 -2
- package/dist/observability/emit-event.js +2 -2
- package/dist/observability/emit-event.js.map +1 -1
- package/dist/operator-errors.d.ts +14 -0
- package/dist/operator-errors.js +39 -10
- package/dist/operator-errors.js.map +1 -1
- package/dist/plugins/digest.d.ts +1 -0
- package/dist/plugins/digest.js +28 -0
- package/dist/plugins/digest.js.map +1 -0
- package/dist/plugins/index.d.ts +6 -0
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/manifest.d.ts +7 -0
- package/dist/plugins/manifest.js +22 -0
- package/dist/plugins/manifest.js.map +1 -0
- package/dist/plugins/registry.d.ts +9 -0
- package/dist/plugins/registry.js +24 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/resolvers.d.ts +2 -0
- package/dist/plugins/resolvers.js +126 -0
- package/dist/plugins/resolvers.js.map +1 -0
- package/dist/plugins/types.d.ts +35 -0
- package/dist/plugins/types.js +2 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/plugins/validator.d.ts +3 -0
- package/dist/plugins/validator.js +50 -0
- package/dist/plugins/validator.js.map +1 -0
- package/dist/preflight/claude-auth.d.ts +14 -12
- package/dist/preflight/claude-auth.js +23 -37
- package/dist/preflight/claude-auth.js.map +1 -1
- package/dist/preflight/claude-required.d.ts +8 -0
- package/dist/preflight/claude-required.js +17 -0
- package/dist/preflight/claude-required.js.map +1 -0
- package/dist/runner/claude.d.ts +3 -3
- package/dist/runner/claude.js +62 -26
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/runner.d.ts +29 -2
- package/dist/runner/simple.d.ts +2 -2
- package/dist/runner/simple.js +2 -2
- package/dist/runner/simple.js.map +1 -1
- package/dist/scripts/donation-consumption-acceptance.d.ts +71 -0
- package/dist/scripts/donation-consumption-acceptance.js +1117 -0
- package/dist/scripts/donation-consumption-acceptance.js.map +1 -0
- package/dist/scripts/fix-node-pty.mjs +113 -0
- package/dist/setup/claude-code-install.d.ts +19 -0
- package/dist/setup/claude-code-install.js +51 -0
- package/dist/setup/claude-code-install.js.map +1 -0
- package/dist/setup-mode.d.ts +34 -0
- package/dist/setup-mode.js +49 -0
- package/dist/setup-mode.js.map +1 -0
- package/dist/solver-nets/contracts.d.ts +2 -0
- package/dist/solver-nets/contracts.js +2 -0
- package/dist/solver-nets/contracts.js.map +1 -0
- package/dist/solver-nets/prediction-operator-ux.d.ts +112 -0
- package/dist/solver-nets/prediction-operator-ux.js +463 -0
- package/dist/solver-nets/prediction-operator-ux.js.map +1 -0
- package/dist/solver-nets/registry.d.ts +64 -0
- package/dist/solver-nets/registry.js +218 -0
- package/dist/solver-nets/registry.js.map +1 -0
- package/dist/solver-types/_session-derived-distill.d.ts +28 -0
- package/dist/solver-types/_session-derived-distill.js +52 -0
- package/dist/solver-types/_session-derived-distill.js.map +1 -0
- package/dist/solver-types/_session-derived-pool.d.ts +10 -0
- package/dist/solver-types/_session-derived-pool.js +27 -0
- package/dist/solver-types/_session-derived-pool.js.map +1 -0
- package/dist/solver-types/_session-derived-state.d.ts +17 -0
- package/dist/solver-types/_session-derived-state.js +25 -0
- package/dist/solver-types/_session-derived-state.js.map +1 -0
- package/dist/solver-types/_swe-rebench-v2-aggregate.d.ts +31 -0
- package/dist/solver-types/_swe-rebench-v2-aggregate.js +49 -0
- package/dist/solver-types/_swe-rebench-v2-aggregate.js.map +1 -0
- package/dist/solver-types/_swe-rebench-v2-escrow.d.ts +27 -0
- package/dist/solver-types/_swe-rebench-v2-escrow.js +26 -0
- package/dist/solver-types/_swe-rebench-v2-escrow.js.map +1 -0
- package/dist/solver-types/_swe-rebench-v2-pool.d.ts +51 -0
- package/dist/solver-types/_swe-rebench-v2-pool.js +72 -0
- package/dist/solver-types/_swe-rebench-v2-pool.js.map +1 -0
- package/dist/solver-types/_swe-rebench-v2-state.d.ts +24 -0
- package/dist/solver-types/_swe-rebench-v2-state.js +54 -0
- package/dist/solver-types/_swe-rebench-v2-state.js.map +1 -0
- package/dist/solver-types/constants.d.ts +5 -0
- package/dist/solver-types/constants.js +6 -0
- package/dist/solver-types/constants.js.map +1 -0
- package/dist/solver-types/index.d.ts +10 -0
- package/dist/solver-types/index.js +32 -0
- package/dist/solver-types/index.js.map +1 -0
- package/dist/solver-types/learner-loop-test.d.ts +2 -0
- package/dist/solver-types/learner-loop-test.js +39 -0
- package/dist/solver-types/learner-loop-test.js.map +1 -0
- package/dist/solver-types/portfolio-v0.d.ts +2 -0
- package/dist/solver-types/portfolio-v0.js +13 -0
- package/dist/solver-types/portfolio-v0.js.map +1 -0
- package/dist/solver-types/prediction-apy-v0-auto.d.ts +27 -0
- package/dist/solver-types/prediction-apy-v0-auto.js +109 -0
- package/dist/solver-types/prediction-apy-v0-auto.js.map +1 -0
- package/dist/solver-types/prediction-apy-v0-template.d.ts +8 -0
- package/dist/solver-types/prediction-apy-v0-template.js +22 -0
- package/dist/solver-types/prediction-apy-v0-template.js.map +1 -0
- package/dist/solver-types/prediction-apy-v0.d.ts +3 -0
- package/dist/solver-types/prediction-apy-v0.js +25 -0
- package/dist/solver-types/prediction-apy-v0.js.map +1 -0
- package/dist/solver-types/prediction-v0-auto.d.ts +69 -0
- package/dist/solver-types/prediction-v0-auto.js +146 -0
- package/dist/solver-types/prediction-v0-auto.js.map +1 -0
- package/dist/solver-types/prediction-v0-template.d.ts +70 -0
- package/dist/solver-types/prediction-v0-template.js +145 -0
- package/dist/solver-types/prediction-v0-template.js.map +1 -0
- package/dist/solver-types/prediction-v0.d.ts +13 -0
- package/dist/solver-types/prediction-v0.js +31 -0
- package/dist/solver-types/prediction-v0.js.map +1 -0
- package/dist/solver-types/prediction-v1-auto.d.ts +122 -0
- package/dist/solver-types/prediction-v1-auto.js +366 -0
- package/dist/solver-types/prediction-v1-auto.js.map +1 -0
- package/dist/solver-types/prediction-v1.d.ts +11 -0
- package/dist/solver-types/prediction-v1.js +27 -0
- package/dist/solver-types/prediction-v1.js.map +1 -0
- package/dist/solver-types/session-derived.d.ts +2 -0
- package/dist/solver-types/session-derived.js +24 -0
- package/dist/solver-types/session-derived.js.map +1 -0
- package/dist/solver-types/solver-type.d.ts +53 -0
- package/dist/solver-types/solver-type.js +6 -0
- package/dist/solver-types/solver-type.js.map +1 -0
- package/dist/solver-types/swe-rebench-v2-auto.d.ts +38 -0
- package/dist/solver-types/swe-rebench-v2-auto.js +56 -0
- package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -0
- package/dist/solver-types/swe-rebench-v2.d.ts +69 -0
- package/dist/solver-types/swe-rebench-v2.js +356 -0
- package/dist/solver-types/swe-rebench-v2.js.map +1 -0
- package/dist/solvernets/daemon-init.d.ts +291 -0
- package/dist/solvernets/daemon-init.js +431 -0
- package/dist/solvernets/daemon-init.js.map +1 -0
- package/dist/solvernets/launch-state-machine.d.ts +165 -0
- package/dist/solvernets/launch-state-machine.js +406 -0
- package/dist/solvernets/launch-state-machine.js.map +1 -0
- package/dist/solvernets/launched-record-dispatcher.d.ts +55 -0
- package/dist/solvernets/launched-record-dispatcher.js +169 -0
- package/dist/solvernets/launched-record-dispatcher.js.map +1 -0
- package/dist/solvernets/lifecycle-transitions.d.ts +183 -0
- package/dist/solvernets/lifecycle-transitions.js +386 -0
- package/dist/solvernets/lifecycle-transitions.js.map +1 -0
- package/dist/solvernets/manifest.d.ts +120 -0
- package/dist/solvernets/manifest.js +166 -0
- package/dist/solvernets/manifest.js.map +1 -0
- package/dist/solvernets/most-recent-wins.d.ts +77 -0
- package/dist/solvernets/most-recent-wins.js +82 -0
- package/dist/solvernets/most-recent-wins.js.map +1 -0
- package/dist/solvernets/registry-client-erc8004.d.ts +239 -0
- package/dist/solvernets/registry-client-erc8004.js +382 -0
- package/dist/solvernets/registry-client-erc8004.js.map +1 -0
- package/dist/solvernets/registry-client.d.ts +121 -0
- package/dist/solvernets/registry-client.js +19 -0
- package/dist/solvernets/registry-client.js.map +1 -0
- package/dist/solvernets/store.d.ts +298 -0
- package/dist/solvernets/store.js +271 -0
- package/dist/solvernets/store.js.map +1 -0
- package/dist/store/captures.d.ts +85 -0
- package/dist/store/captures.js +167 -0
- package/dist/store/captures.js.map +1 -0
- package/dist/store/store.d.ts +235 -21
- package/dist/store/store.js +1000 -46
- package/dist/store/store.js.map +1 -1
- package/dist/tasks/posting-service.d.ts +25 -0
- package/dist/tasks/posting-service.js +149 -0
- package/dist/tasks/posting-service.js.map +1 -0
- package/dist/tasks/signing.d.ts +4 -0
- package/dist/tasks/signing.js +18 -0
- package/dist/tasks/signing.js.map +1 -0
- package/dist/tasks/sources.d.ts +46 -0
- package/dist/tasks/sources.js +45 -0
- package/dist/tasks/sources.js.map +1 -0
- package/dist/templates/harnesses/alternative-harness/README.md.tmpl +44 -0
- package/dist/templates/harnesses/alternative-harness/gitignore.tmpl +3 -0
- package/dist/templates/harnesses/alternative-harness/jinn.manifest.json.tmpl +22 -0
- package/dist/templates/harnesses/alternative-harness/package.json.tmpl +26 -0
- package/dist/templates/harnesses/alternative-harness/src/coordinator.ts.tmpl +50 -0
- package/dist/templates/harnesses/alternative-harness/src/harness.ts.tmpl +31 -0
- package/dist/templates/harnesses/alternative-harness/src/index.ts.tmpl +44 -0
- package/dist/templates/harnesses/alternative-harness/src/mock-harness.ts.tmpl +41 -0
- package/dist/templates/harnesses/alternative-harness/src/phases/debrief.ts.tmpl +28 -0
- package/dist/templates/harnesses/alternative-harness/src/phases/execute.ts.tmpl +33 -0
- package/dist/templates/harnesses/alternative-harness/src/phases/improve.ts.tmpl +31 -0
- package/dist/templates/harnesses/alternative-harness/src/phases/memory.ts.tmpl +31 -0
- package/dist/templates/harnesses/alternative-harness/src/phases/orient.ts.tmpl +21 -0
- package/dist/templates/harnesses/alternative-harness/src/phases/plan.ts.tmpl +25 -0
- package/dist/templates/harnesses/alternative-harness/src/phases/strategize.ts.tmpl +29 -0
- package/dist/templates/harnesses/alternative-harness/test/coordinator.test.ts.tmpl +53 -0
- package/dist/templates/harnesses/alternative-harness/test/unit.test.ts.tmpl +55 -0
- package/dist/templates/harnesses/alternative-harness/tsconfig.json.tmpl +16 -0
- package/dist/templates/harnesses/evaluator/README.md.tmpl +36 -0
- package/dist/templates/harnesses/evaluator/gitignore.tmpl +3 -0
- package/dist/templates/harnesses/evaluator/jinn.manifest.json.tmpl +22 -0
- package/dist/templates/harnesses/evaluator/package.json.tmpl +26 -0
- package/dist/templates/harnesses/evaluator/src/index.ts.tmpl +35 -0
- package/dist/templates/harnesses/evaluator/test/unit.test.ts.tmpl +49 -0
- package/dist/templates/harnesses/evaluator/tsconfig.json.tmpl +16 -0
- package/dist/templates/harnesses/forecaster/README.md.tmpl +25 -0
- package/dist/templates/harnesses/forecaster/gitignore.tmpl +5 -0
- package/dist/templates/harnesses/forecaster/jinn.manifest.json.tmpl +22 -0
- package/dist/templates/harnesses/forecaster/package.json.tmpl +26 -0
- package/dist/templates/harnesses/forecaster/src/index.ts.tmpl +33 -0
- package/dist/templates/harnesses/forecaster/test/unit.test.ts.tmpl +42 -0
- package/dist/templates/harnesses/forecaster/tsconfig.json.tmpl +16 -0
- package/dist/trajectory/collector.d.ts +59 -0
- package/dist/trajectory/collector.js +164 -0
- package/dist/trajectory/collector.js.map +1 -0
- package/dist/trajectory/emit.d.ts +29 -0
- package/dist/trajectory/emit.js +81 -0
- package/dist/trajectory/emit.js.map +1 -0
- package/dist/trajectory/harness-bundle-rules/aider.d.ts +13 -0
- package/dist/trajectory/harness-bundle-rules/aider.js +26 -0
- package/dist/trajectory/harness-bundle-rules/aider.js.map +1 -0
- package/dist/trajectory/harness-bundle-rules/claude-code.d.ts +16 -0
- package/dist/trajectory/harness-bundle-rules/claude-code.js +71 -0
- package/dist/trajectory/harness-bundle-rules/claude-code.js.map +1 -0
- package/dist/trajectory/harness-bundle-rules/codex.d.ts +13 -0
- package/dist/trajectory/harness-bundle-rules/codex.js +96 -0
- package/dist/trajectory/harness-bundle-rules/codex.js.map +1 -0
- package/dist/trajectory/harness-bundle-rules/continue.d.ts +10 -0
- package/dist/trajectory/harness-bundle-rules/continue.js +43 -0
- package/dist/trajectory/harness-bundle-rules/continue.js.map +1 -0
- package/dist/trajectory/harness-bundle-rules/cursor.d.ts +20 -0
- package/dist/trajectory/harness-bundle-rules/cursor.js +55 -0
- package/dist/trajectory/harness-bundle-rules/cursor.js.map +1 -0
- package/dist/trajectory/harness-bundle-rules/gemini-cli.d.ts +15 -0
- package/dist/trajectory/harness-bundle-rules/gemini-cli.js +112 -0
- package/dist/trajectory/harness-bundle-rules/gemini-cli.js.map +1 -0
- package/dist/trajectory/harness-bundle-rules/types.d.ts +25 -0
- package/dist/trajectory/harness-bundle-rules/types.js +15 -0
- package/dist/trajectory/harness-bundle-rules/types.js.map +1 -0
- package/dist/trajectory/harness-bundle-schema.d.ts +74 -0
- package/dist/trajectory/harness-bundle-schema.js +34 -0
- package/dist/trajectory/harness-bundle-schema.js.map +1 -0
- package/dist/trajectory/harness-bundle.d.ts +73 -0
- package/dist/trajectory/harness-bundle.js +128 -0
- package/dist/trajectory/harness-bundle.js.map +1 -0
- package/dist/trajectory/hash-chain.d.ts +18 -0
- package/dist/trajectory/hash-chain.js +23 -0
- package/dist/trajectory/hash-chain.js.map +1 -0
- package/dist/trajectory/index.d.ts +28 -0
- package/dist/trajectory/index.js +28 -0
- package/dist/trajectory/index.js.map +1 -0
- package/dist/trajectory/llm-proxy-spans.d.ts +14 -0
- package/dist/trajectory/llm-proxy-spans.js +51 -0
- package/dist/trajectory/llm-proxy-spans.js.map +1 -0
- package/dist/trajectory/llm-proxy.d.ts +32 -0
- package/dist/trajectory/llm-proxy.js +97 -0
- package/dist/trajectory/llm-proxy.js.map +1 -0
- package/dist/trajectory/processors/credential-scrub.d.ts +11 -0
- package/dist/trajectory/processors/credential-scrub.js +40 -0
- package/dist/trajectory/processors/credential-scrub.js.map +1 -0
- package/dist/trajectory/processors/identity-scrub.d.ts +18 -0
- package/dist/trajectory/processors/identity-scrub.js +43 -0
- package/dist/trajectory/processors/identity-scrub.js.map +1 -0
- package/dist/trajectory/processors/manifest-builder.d.ts +18 -0
- package/dist/trajectory/processors/manifest-builder.js +26 -0
- package/dist/trajectory/processors/manifest-builder.js.map +1 -0
- package/dist/trajectory/processors/path-scrub.d.ts +15 -0
- package/dist/trajectory/processors/path-scrub.js +52 -0
- package/dist/trajectory/processors/path-scrub.js.map +1 -0
- package/dist/trajectory/processors/sentinel.d.ts +16 -0
- package/dist/trajectory/processors/sentinel.js +17 -0
- package/dist/trajectory/processors/sentinel.js.map +1 -0
- package/dist/trajectory/processors/sqlite-exporter.d.ts +32 -0
- package/dist/trajectory/processors/sqlite-exporter.js +48 -0
- package/dist/trajectory/processors/sqlite-exporter.js.map +1 -0
- package/dist/trajectory/processors/transcript-content-scrub.d.ts +9 -0
- package/dist/trajectory/processors/transcript-content-scrub.js +58 -0
- package/dist/trajectory/processors/transcript-content-scrub.js.map +1 -0
- package/dist/trajectory/receiver.d.ts +37 -0
- package/dist/trajectory/receiver.js +584 -0
- package/dist/trajectory/receiver.js.map +1 -0
- package/dist/trajectory/schema.d.ts +102 -14
- package/dist/trajectory/schema.js +29 -0
- package/dist/trajectory/schema.js.map +1 -1
- package/dist/trajectory/secret-scrub.d.ts +32 -0
- package/dist/trajectory/secret-scrub.js +51 -0
- package/dist/trajectory/secret-scrub.js.map +1 -0
- package/dist/trajectory/span-profile.d.ts +27 -0
- package/dist/trajectory/span-profile.js +51 -0
- package/dist/trajectory/span-profile.js.map +1 -0
- package/dist/trajectory/synthetic-span-builder.d.ts +50 -0
- package/dist/trajectory/synthetic-span-builder.js +115 -0
- package/dist/trajectory/synthetic-span-builder.js.map +1 -0
- package/dist/trajectory/transcript-parsers/aider-history.d.ts +42 -0
- package/dist/trajectory/transcript-parsers/aider-history.js +182 -0
- package/dist/trajectory/transcript-parsers/aider-history.js.map +1 -0
- package/dist/trajectory/transcript-parsers/claude-code-jsonl.d.ts +37 -0
- package/dist/trajectory/transcript-parsers/claude-code-jsonl.js +143 -0
- package/dist/trajectory/transcript-parsers/claude-code-jsonl.js.map +1 -0
- package/dist/trajectory/transcript-parsers/codex-session.d.ts +36 -0
- package/dist/trajectory/transcript-parsers/codex-session.js +135 -0
- package/dist/trajectory/transcript-parsers/codex-session.js.map +1 -0
- package/dist/trajectory/transcript-parsers/continue-devdata.d.ts +41 -0
- package/dist/trajectory/transcript-parsers/continue-devdata.js +191 -0
- package/dist/trajectory/transcript-parsers/continue-devdata.js.map +1 -0
- package/dist/trajectory/transcript-parsers/cursor-sqlite.d.ts +38 -0
- package/dist/trajectory/transcript-parsers/cursor-sqlite.js +119 -0
- package/dist/trajectory/transcript-parsers/cursor-sqlite.js.map +1 -0
- package/dist/trajectory/transcript-parsers/gemini-session.d.ts +35 -0
- package/dist/trajectory/transcript-parsers/gemini-session.js +138 -0
- package/dist/trajectory/transcript-parsers/gemini-session.js.map +1 -0
- package/dist/trajectory/transcript-parsers/types.d.ts +101 -0
- package/dist/trajectory/transcript-parsers/types.js +33 -0
- package/dist/trajectory/transcript-parsers/types.js.map +1 -0
- package/dist/trajectory/transcript-watcher.d.ts +62 -0
- package/dist/trajectory/transcript-watcher.js +157 -0
- package/dist/trajectory/transcript-watcher.js.map +1 -0
- package/dist/trajectory/wrappers/http.d.ts +37 -0
- package/dist/trajectory/wrappers/http.js +85 -0
- package/dist/trajectory/wrappers/http.js.map +1 -0
- package/dist/trajectory/wrappers/mcp.d.ts +17 -0
- package/dist/trajectory/wrappers/mcp.js +58 -0
- package/dist/trajectory/wrappers/mcp.js.map +1 -0
- package/dist/trajectory/wrappers/subprocess.d.ts +32 -0
- package/dist/trajectory/wrappers/subprocess.js +70 -0
- package/dist/trajectory/wrappers/subprocess.js.map +1 -0
- package/dist/tx-retry.js +90 -9
- package/dist/tx-retry.js.map +1 -1
- package/dist/types/envelope.d.ts +2742 -0
- package/dist/types/envelope.js +149 -0
- package/dist/types/envelope.js.map +1 -0
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.js +4 -4
- package/dist/types/index.js.map +1 -1
- package/dist/types/payloads/index.d.ts +12 -0
- package/dist/types/payloads/index.js +62 -0
- package/dist/types/payloads/index.js.map +1 -0
- package/dist/types/payloads/portfolio-v0.d.ts +481 -0
- package/dist/types/payloads/portfolio-v0.js +94 -0
- package/dist/types/payloads/portfolio-v0.js.map +1 -0
- package/dist/types/payloads/prediction-apy-v0.d.ts +231 -0
- package/dist/types/payloads/prediction-apy-v0.js +63 -0
- package/dist/types/payloads/prediction-apy-v0.js.map +1 -0
- package/dist/types/payloads/prediction-v0.d.ts +262 -0
- package/dist/types/payloads/prediction-v0.js +73 -0
- package/dist/types/payloads/prediction-v0.js.map +1 -0
- package/dist/types/payloads/prediction-v1.d.ts +2 -0
- package/dist/types/payloads/prediction-v1.js +2 -0
- package/dist/types/payloads/prediction-v1.js.map +1 -0
- package/dist/types/portfolio.d.ts +31 -698
- package/dist/types/portfolio.js +20 -110
- package/dist/types/portfolio.js.map +1 -1
- package/dist/types/prediction-apy.d.ts +26 -366
- package/dist/types/prediction-apy.js +12 -68
- package/dist/types/prediction-apy.js.map +1 -1
- package/dist/types/prediction-v1.d.ts +2 -0
- package/dist/types/prediction-v1.js +2 -0
- package/dist/types/prediction-v1.js.map +1 -0
- package/dist/types/prediction.d.ts +546 -382
- package/dist/types/prediction.js +16 -87
- package/dist/types/prediction.js.map +1 -1
- package/dist/types/session-provenance.d.ts +71 -0
- package/dist/types/session-provenance.js +19 -0
- package/dist/types/session-provenance.js.map +1 -0
- package/dist/types/task-document.d.ts +1121 -0
- package/dist/types/task-document.js +99 -0
- package/dist/types/task-document.js.map +1 -0
- package/dist/types/task.d.ts +805 -0
- package/dist/types/task.js +88 -0
- package/dist/types/task.js.map +1 -0
- package/dist/types/window.d.ts +12 -0
- package/dist/types/window.js +6 -0
- package/dist/types/window.js.map +1 -0
- package/dist/util/path-safety.d.ts +21 -0
- package/dist/util/path-safety.js +28 -0
- package/dist/util/path-safety.js.map +1 -0
- package/dist/util/redact-rpc-urls.d.ts +5 -0
- package/dist/util/redact-rpc-urls.js +9 -0
- package/dist/util/redact-rpc-urls.js.map +1 -0
- package/dist/vendor/@jinn-network/sdk/README.md +89 -0
- package/dist/vendor/@jinn-network/sdk/dist/capabilities.d.ts +52 -0
- package/dist/vendor/@jinn-network/sdk/dist/capabilities.js +1 -0
- package/dist/vendor/@jinn-network/sdk/dist/checkpoint.d.ts +120 -0
- package/dist/vendor/@jinn-network/sdk/dist/checkpoint.js +39 -0
- package/dist/vendor/@jinn-network/sdk/dist/contracts.d.ts +145 -0
- package/dist/vendor/@jinn-network/sdk/dist/contracts.js +317 -0
- package/dist/vendor/@jinn-network/sdk/dist/harness.d.ts +120 -0
- package/dist/vendor/@jinn-network/sdk/dist/harness.js +31 -0
- package/dist/vendor/@jinn-network/sdk/dist/index.d.ts +4 -0
- package/dist/vendor/@jinn-network/sdk/dist/index.js +7 -0
- package/dist/vendor/@jinn-network/sdk/dist/json-schema.d.ts +32 -0
- package/dist/vendor/@jinn-network/sdk/dist/json-schema.js +131 -0
- package/dist/vendor/@jinn-network/sdk/dist/manifest.d.ts +69 -0
- package/dist/vendor/@jinn-network/sdk/dist/manifest.js +3 -0
- package/dist/vendor/@jinn-network/sdk/dist/payloads/prediction-v1.d.ts +223 -0
- package/dist/vendor/@jinn-network/sdk/dist/payloads/prediction-v1.js +64 -0
- package/dist/vendor/@jinn-network/sdk/dist/payloads/session-derived.d.ts +359 -0
- package/dist/vendor/@jinn-network/sdk/dist/payloads/session-derived.js +60 -0
- package/dist/vendor/@jinn-network/sdk/dist/payloads/swe-rebench-v2.d.ts +110 -0
- package/dist/vendor/@jinn-network/sdk/dist/payloads/swe-rebench-v2.js +58 -0
- package/dist/vendor/@jinn-network/sdk/dist/plugins.d.ts +36 -0
- package/dist/vendor/@jinn-network/sdk/dist/plugins.js +54 -0
- package/dist/vendor/@jinn-network/sdk/dist/prediction-v1.d.ts +870 -0
- package/dist/vendor/@jinn-network/sdk/dist/prediction-v1.js +80 -0
- package/dist/vendor/@jinn-network/sdk/dist/session-derived/distill-prompt-v1.d.ts +2 -0
- package/dist/vendor/@jinn-network/sdk/dist/session-derived/distill-prompt-v1.js +10 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/index.d.ts +6 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/index.js +8 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.d.ts +559 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.js +126 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/prediction-v1.d.ts +6 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/prediction-v1.js +3 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2.d.ts +4 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2.js +2 -0
- package/dist/vendor/@jinn-network/sdk/dist/swe-rebench-v2.d.ts +66 -0
- package/dist/vendor/@jinn-network/sdk/dist/swe-rebench-v2.js +44 -0
- package/dist/vendor/@jinn-network/sdk/dist/types.d.ts +116 -0
- package/dist/vendor/@jinn-network/sdk/dist/types.js +21 -0
- package/dist/vendor/@jinn-network/sdk/package.json +43 -0
- package/dist/venues/hyperliquid/account-value.d.ts +1 -1
- package/dist/venues/hyperliquid/account-value.js +1 -1
- package/dist/venues/polymarket/client.d.ts +77 -0
- package/dist/venues/polymarket/client.js +309 -0
- package/dist/venues/polymarket/client.js.map +1 -0
- package/dist/withdraw/run-withdraw-plan.js +0 -2
- package/dist/withdraw/run-withdraw-plan.js.map +1 -1
- package/dist/x402/acquire.d.ts +14 -3
- package/dist/x402/acquire.js +28 -11
- package/dist/x402/acquire.js.map +1 -1
- package/dist/x402/handler.d.ts +15 -3
- package/dist/x402/handler.js +189 -24
- package/dist/x402/handler.js.map +1 -1
- package/package.json +60 -15
- package/plugins/claude-code-learner/.claude-plugin/plugin.json +9 -0
- package/plugins/claude-code-learner/.codex-plugin/plugin.json +39 -0
- package/plugins/claude-code-learner/AGENTS.md +40 -0
- package/plugins/claude-code-learner/CLAUDE.md +33 -0
- package/plugins/claude-code-learner/README.md +59 -0
- package/plugins/claude-code-learner/hooks/hooks.json +16 -0
- package/plugins/claude-code-learner/hooks/session-start +38 -0
- package/plugins/claude-code-learner/skills/learn/SKILL.md +412 -0
- package/plugins/claude-code-learner/skills/learn/analyst-prompt.md +68 -0
- package/plugins/claude-code-learner/skills/learn/consolidator-prompt.md +94 -0
- package/plugins/claude-code-learner/skills/learn/explorer-prompt.md +53 -0
- package/plugins/claude-code-learner/skills/learn/planner-prompt.md +87 -0
- package/plugins/claude-code-learner/skills/learn/promoter-prompt.md +113 -0
- package/plugins/claude-code-learner/skills/learn/step-worker-prompt.md +47 -0
- package/plugins/claude-code-learner/skills/learn/strategist-prompt.md +85 -0
- package/plugins/jinn-prediction-plugin/.claude-plugin/plugin.json +19 -0
- package/plugins/jinn-prediction-plugin/.mcp.json +8 -0
- package/plugins/jinn-prediction-plugin/GEMINI.md +7 -0
- package/plugins/jinn-prediction-plugin/gemini-extension.json +13 -0
- package/plugins/jinn-prediction-plugin/jinn.plugin.json +26 -0
- package/plugins/jinn-prediction-plugin/mcp/polymarket-server.mjs +322 -0
- package/plugins/jinn-prediction-plugin/schemas/prediction-v0-solution.schema.json +12 -0
- package/plugins/jinn-prediction-plugin/schemas/prediction-v0-task.schema.json +25 -0
- package/plugins/jinn-prediction-plugin/schemas/prediction-v0-verdict.schema.json +11 -0
- package/plugins/jinn-prediction-plugin/schemas/prediction-v1-solution.schema.json +34 -0
- package/plugins/jinn-prediction-plugin/schemas/prediction-v1-task.schema.json +118 -0
- package/plugins/jinn-prediction-plugin/schemas/prediction-v1-verdict.schema.json +84 -0
- package/plugins/jinn-prediction-plugin/skills/base-rate-forecasting/SKILL.md +3 -0
- package/plugins/jinn-prediction-plugin/skills/calibration/SKILL.md +3 -0
- package/plugins/jinn-prediction-plugin/skills/common-biases/SKILL.md +3 -0
- package/plugins/jinn-prediction-plugin/skills/polymarket-task-handling/SKILL.md +5 -0
- package/plugins/jinn-prediction-plugin/skills/prediction-corpus-retrieval/SKILL.md +35 -0
- package/plugins/network-tools/.claude-plugin/plugin.json +12 -0
- package/plugins/network-tools/.codex-plugin/plugin.json +39 -0
- package/plugins/network-tools/.mcp.json +11 -0
- package/plugins/network-tools/jinn.plugin.json +29 -0
- package/plugins/network-tools/mcp/jinn-client-server.mjs +110 -0
- package/plugins/swe-rebench-v2-runtime/.claude-plugin/plugin.json +5 -0
- package/plugins/swe-rebench-v2-runtime/.codex-plugin/plugin.json +39 -0
- package/plugins/swe-rebench-v2-runtime/README.md +11 -0
- package/plugins/swe-rebench-v2-runtime/jinn.plugin.json +12 -0
- package/plugins/swe-rebench-v2-runtime/skills/orient/SKILL.md +25 -0
- package/plugins/swe-rebench-v2-runtime/skills/plan/SKILL.md +64 -0
- package/skills/jinn-operator/SKILL.md +120 -101
- package/templates/harnesses/alternative-harness/README.md.tmpl +44 -0
- package/templates/harnesses/alternative-harness/gitignore.tmpl +3 -0
- package/templates/harnesses/alternative-harness/jinn.manifest.json.tmpl +22 -0
- package/templates/harnesses/alternative-harness/package.json.tmpl +26 -0
- package/templates/harnesses/alternative-harness/src/coordinator.ts.tmpl +50 -0
- package/templates/harnesses/alternative-harness/src/harness.ts.tmpl +31 -0
- package/templates/harnesses/alternative-harness/src/index.ts.tmpl +44 -0
- package/templates/harnesses/alternative-harness/src/mock-harness.ts.tmpl +41 -0
- package/templates/harnesses/alternative-harness/src/phases/debrief.ts.tmpl +28 -0
- package/templates/harnesses/alternative-harness/src/phases/execute.ts.tmpl +33 -0
- package/templates/harnesses/alternative-harness/src/phases/improve.ts.tmpl +31 -0
- package/templates/harnesses/alternative-harness/src/phases/memory.ts.tmpl +31 -0
- package/templates/harnesses/alternative-harness/src/phases/orient.ts.tmpl +21 -0
- package/templates/harnesses/alternative-harness/src/phases/plan.ts.tmpl +25 -0
- package/templates/harnesses/alternative-harness/src/phases/strategize.ts.tmpl +29 -0
- package/templates/harnesses/alternative-harness/test/coordinator.test.ts.tmpl +53 -0
- package/templates/harnesses/alternative-harness/test/unit.test.ts.tmpl +55 -0
- package/templates/harnesses/alternative-harness/tsconfig.json.tmpl +16 -0
- package/templates/harnesses/evaluator/README.md.tmpl +36 -0
- package/templates/harnesses/evaluator/gitignore.tmpl +3 -0
- package/templates/harnesses/evaluator/jinn.manifest.json.tmpl +22 -0
- package/templates/harnesses/evaluator/package.json.tmpl +26 -0
- package/templates/harnesses/evaluator/src/index.ts.tmpl +35 -0
- package/templates/harnesses/evaluator/test/unit.test.ts.tmpl +49 -0
- package/templates/harnesses/evaluator/tsconfig.json.tmpl +16 -0
- package/templates/harnesses/forecaster/README.md.tmpl +25 -0
- package/templates/harnesses/forecaster/gitignore.tmpl +5 -0
- package/templates/harnesses/forecaster/jinn.manifest.json.tmpl +22 -0
- package/templates/harnesses/forecaster/package.json.tmpl +26 -0
- package/templates/harnesses/forecaster/src/index.ts.tmpl +33 -0
- package/templates/harnesses/forecaster/test/unit.test.ts.tmpl +42 -0
- package/templates/harnesses/forecaster/tsconfig.json.tmpl +16 -0
- package/dist/adapters/claim-registry/abi.d.ts +0 -127
- package/dist/adapters/claim-registry/abi.js +0 -93
- package/dist/adapters/claim-registry/abi.js.map +0 -1
- package/dist/adapters/claim-registry/client.d.ts +0 -89
- package/dist/adapters/claim-registry/client.js +0 -205
- package/dist/adapters/claim-registry/client.js.map +0 -1
- package/dist/adapters/mech/claim-policy.d.ts +0 -40
- package/dist/adapters/mech/claim-policy.js +0 -104
- package/dist/adapters/mech/claim-policy.js.map +0 -1
- package/dist/bin/jinn-mcp.d.ts +0 -2
- package/dist/bin/jinn-mcp.js +0 -10
- package/dist/bin/jinn-mcp.js.map +0 -1
- package/dist/cli/commands/intents.d.ts +0 -17
- package/dist/cli/commands/intents.js +0 -489
- package/dist/cli/commands/intents.js.map +0 -1
- package/dist/cli/commands/plugin-install.js +0 -803
- package/dist/cli/commands/plugin-install.js.map +0 -1
- package/dist/cli/commands/submit-intent.js +0 -245
- package/dist/cli/commands/submit-intent.js.map +0 -1
- package/dist/cli/intent-registry-access.d.ts +0 -62
- package/dist/cli/intent-registry-access.js +0 -165
- package/dist/cli/intent-registry-access.js.map +0 -1
- package/dist/discovery/registry.d.ts +0 -97
- package/dist/discovery/registry.js +0 -177
- package/dist/discovery/registry.js.map +0 -1
- package/dist/discovery/subgraph.d.ts +0 -37
- package/dist/discovery/subgraph.js +0 -87
- package/dist/discovery/subgraph.js.map +0 -1
- package/dist/intents/kinds/constants.d.ts +0 -5
- package/dist/intents/kinds/constants.js +0 -6
- package/dist/intents/kinds/constants.js.map +0 -1
- package/dist/intents/kinds/index.d.ts +0 -28
- package/dist/intents/kinds/index.js +0 -50
- package/dist/intents/kinds/index.js.map +0 -1
- package/dist/intents/kinds/portfolio-v0.d.ts +0 -2
- package/dist/intents/kinds/portfolio-v0.js +0 -13
- package/dist/intents/kinds/portfolio-v0.js.map +0 -1
- package/dist/intents/kinds/prediction-apy-v0.d.ts +0 -3
- package/dist/intents/kinds/prediction-apy-v0.js +0 -21
- package/dist/intents/kinds/prediction-apy-v0.js.map +0 -1
- package/dist/intents/kinds/prediction-v0.d.ts +0 -3
- package/dist/intents/kinds/prediction-v0.js +0 -32
- package/dist/intents/kinds/prediction-v0.js.map +0 -1
- package/dist/intents/kinds/spec-kind.d.ts +0 -38
- package/dist/intents/kinds/spec-kind.js +0 -6
- package/dist/intents/kinds/spec-kind.js.map +0 -1
- package/dist/intents/posting-service.d.ts +0 -26
- package/dist/intents/posting-service.js +0 -218
- package/dist/intents/posting-service.js.map +0 -1
- package/dist/intents/prediction-apy-v0-auto.d.ts +0 -11
- package/dist/intents/prediction-apy-v0-auto.js +0 -46
- package/dist/intents/prediction-apy-v0-auto.js.map +0 -1
- package/dist/intents/prediction-apy-v0-template.d.ts +0 -8
- package/dist/intents/prediction-apy-v0-template.js +0 -22
- package/dist/intents/prediction-apy-v0-template.js.map +0 -1
- package/dist/intents/prediction-v0-auto.d.ts +0 -53
- package/dist/intents/prediction-v0-auto.js +0 -84
- package/dist/intents/prediction-v0-auto.js.map +0 -1
- package/dist/intents/prediction-v0-template.d.ts +0 -70
- package/dist/intents/prediction-v0-template.js +0 -145
- package/dist/intents/prediction-v0-template.js.map +0 -1
- package/dist/intents/sources.d.ts +0 -39
- package/dist/intents/sources.js +0 -42
- package/dist/intents/sources.js.map +0 -1
- package/dist/restorer/engine/canonical-json.d.ts +0 -18
- package/dist/restorer/engine/canonical-json.js +0 -59
- package/dist/restorer/engine/canonical-json.js.map +0 -1
- package/dist/restorer/engine/claim.d.ts +0 -69
- package/dist/restorer/engine/claim.js +0 -104
- package/dist/restorer/engine/claim.js.map +0 -1
- package/dist/restorer/engine/delivery.d.ts +0 -52
- package/dist/restorer/engine/delivery.js +0 -63
- package/dist/restorer/engine/delivery.js.map +0 -1
- package/dist/restorer/engine/engine.d.ts +0 -213
- package/dist/restorer/engine/engine.js +0 -769
- package/dist/restorer/engine/engine.js.map +0 -1
- package/dist/restorer/engine/manifest-assembly.d.ts +0 -67
- package/dist/restorer/engine/manifest-assembly.js +0 -79
- package/dist/restorer/engine/manifest-assembly.js.map +0 -1
- package/dist/restorer/engine/packaging.d.ts +0 -87
- package/dist/restorer/engine/packaging.js +0 -350
- package/dist/restorer/engine/packaging.js.map +0 -1
- package/dist/restorer/engine/persistence.d.ts +0 -170
- package/dist/restorer/engine/persistence.js +0 -381
- package/dist/restorer/engine/persistence.js.map +0 -1
- package/dist/restorer/engine/recovery.d.ts +0 -22
- package/dist/restorer/engine/recovery.js +0 -24
- package/dist/restorer/engine/recovery.js.map +0 -1
- package/dist/restorer/engine/registry.d.ts +0 -62
- package/dist/restorer/engine/registry.js +0 -73
- package/dist/restorer/engine/registry.js.map +0 -1
- package/dist/restorer/engine/signing.d.ts +0 -30
- package/dist/restorer/engine/signing.js +0 -39
- package/dist/restorer/engine/signing.js.map +0 -1
- package/dist/restorer/engine/state.d.ts +0 -42
- package/dist/restorer/engine/state.js +0 -87
- package/dist/restorer/engine/state.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.d.ts +0 -64
- package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +0 -104
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +0 -721
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +0 -97
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +0 -226
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction/index.d.ts +0 -44
- package/dist/restorer/impls/claude-mcp-prediction/index.js +0 -239
- package/dist/restorer/impls/claude-mcp-prediction/index.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js +0 -135
- package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction/prompt.d.ts +0 -8
- package/dist/restorer/impls/claude-mcp-prediction/prompt.js +0 -54
- package/dist/restorer/impls/claude-mcp-prediction/prompt.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.d.ts +0 -36
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js +0 -137
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction/types.d.ts +0 -84
- package/dist/restorer/impls/claude-mcp-prediction/types.js +0 -6
- package/dist/restorer/impls/claude-mcp-prediction/types.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction-apy/index.d.ts +0 -34
- package/dist/restorer/impls/claude-mcp-prediction-apy/index.js +0 -233
- package/dist/restorer/impls/claude-mcp-prediction-apy/index.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.js +0 -136
- package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.d.ts +0 -7
- package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.js +0 -46
- package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.d.ts +0 -27
- package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js +0 -128
- package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +0 -1
- package/dist/restorer/impls/claude-mcp-prediction-apy/types.d.ts +0 -64
- package/dist/restorer/impls/claude-mcp-prediction-apy/types.js +0 -6
- package/dist/restorer/impls/claude-mcp-prediction-apy/types.js.map +0 -1
- package/dist/restorer/impls/evaluation-context.d.ts +0 -16
- package/dist/restorer/impls/evaluation-context.js +0 -18
- package/dist/restorer/impls/evaluation-context.js.map +0 -1
- package/dist/restorer/impls/index.d.ts +0 -46
- package/dist/restorer/impls/index.js +0 -88
- package/dist/restorer/impls/index.js.map +0 -1
- package/dist/restorer/impls/legacy-claude/index.d.ts +0 -52
- package/dist/restorer/impls/legacy-claude/index.js +0 -140
- package/dist/restorer/impls/legacy-claude/index.js.map +0 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +0 -68
- package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js +0 -117
- package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +0 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +0 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.d.ts +0 -78
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js +0 -274
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +0 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +0 -23
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js +0 -49
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +0 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.d.ts +0 -25
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js +0 -44
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +0 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.d.ts +0 -17
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js +0 -43
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +0 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +0 -44
- package/dist/restorer/impls/portfolio-v0-evaluator/index.js +0 -440
- package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +0 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +0 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/types.d.ts +0 -34
- package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +0 -1
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.d.ts +0 -40
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.js +0 -107
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +0 -1
- package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js.map +0 -1
- package/dist/restorer/impls/prediction-apy-v0-baseline/types.js.map +0 -1
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +0 -6
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +0 -11
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +0 -1
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.d.ts +0 -42
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +0 -208
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +0 -1
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +0 -7
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js +0 -29
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js.map +0 -1
- package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js.map +0 -1
- package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +0 -31
- package/dist/restorer/impls/prediction-v0-baseline/index.js +0 -100
- package/dist/restorer/impls/prediction-v0-baseline/index.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-baseline/strategy.d.ts +0 -8
- package/dist/restorer/impls/prediction-v0-baseline/strategy.js +0 -41
- package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +0 -7
- package/dist/restorer/impls/prediction-v0-baseline/types.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.d.ts +0 -20
- package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.d.ts +0 -9
- package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.d.ts +0 -3
- package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +0 -13
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +0 -111
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.d.ts +0 -5
- package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +0 -36
- package/dist/restorer/impls/prediction-v0-evaluator/index.js +0 -234
- package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +0 -1
- package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +0 -1
- package/dist/restorer/types.d.ts +0 -194
- package/dist/restorer/types.js +0 -28
- package/dist/restorer/types.js.map +0 -1
- package/dist/types/desired-state.d.ts +0 -94
- package/dist/types/desired-state.js +0 -36
- package/dist/types/desired-state.js.map +0 -1
- /package/dist/cli/commands/{plugin-install.d.ts → solver-nets.d.ts} +0 -0
- /package/dist/cli/commands/{submit-intent.d.ts → tasks.d.ts} +0 -0
- /package/dist/{restorer/impls/prediction-apy-v0-baseline → harnesses/impls/claude-code-learner}/types.js +0 -0
- /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/api-wallet.js +0 -0
- /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +0 -0
- /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/mcp-tools.js +0 -0
- /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/safety-rails.d.ts +0 -0
- /package/dist/{restorer → harnesses}/impls/claude-mcp-hyperliquid/safety-rails.js +0 -0
- /package/dist/{restorer → harnesses}/impls/claude-mcp-prediction/mcp-tools.d.ts +0 -0
- /package/dist/{restorer → harnesses}/impls/claude-mcp-prediction-apy/mcp-tools.d.ts +0 -0
- /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/availability.d.ts +0 -0
- /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/checks/availability.js +0 -0
- /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/score.d.ts +0 -0
- /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/score.js +0 -0
- /package/dist/{restorer → harnesses}/impls/portfolio-v0-evaluator/types.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/strategy.d.ts +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/strategy.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-baseline/types.d.ts +0 -0
- /package/dist/{restorer/impls/prediction-apy-v0-evaluator → harnesses/impls/prediction-apy-v0-baseline}/types.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/score.d.ts +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/score.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-apy-v0-evaluator/types.d.ts +0 -0
- /package/dist/{restorer/impls/prediction-v0-baseline → harnesses/impls/prediction-apy-v0-evaluator}/types.js +0 -0
- /package/dist/{restorer/impls/prediction-v0-evaluator → harnesses/impls/prediction-v0-baseline}/types.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/canonical-metrics.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/availability.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/eligibility.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/checks/spec.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/score.d.ts +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/score.js +0 -0
- /package/dist/{restorer → harnesses}/impls/prediction-v0-evaluator/types.d.ts +0 -0
|
@@ -0,0 +1,1588 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness engine — main TaskEngine class.
|
|
3
|
+
*
|
|
4
|
+
* §6.3, §6.5 of spec/2026-04-17-portfolio-v0-design.md
|
|
5
|
+
*
|
|
6
|
+
* Orchestrates the state machine lifecycle for each observed task.
|
|
7
|
+
* Transition method bodies are stubs; subsequent tasks fill them in.
|
|
8
|
+
*/
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
11
|
+
import { keccak256, toBytes } from 'viem';
|
|
12
|
+
import { TaskRunPersistence } from './persistence.js';
|
|
13
|
+
import { TaskRunState, MissingEvidenceHashError } from './state.js';
|
|
14
|
+
import { provisionWorkingDir, provisionImplStateDir, walkArtifacts, uploadArtifacts, } from './packaging.js';
|
|
15
|
+
import { DONATION_ARTIFACT_ENCODING } from './artifact-scrub.js';
|
|
16
|
+
import { assembleAndSignEnvelope, } from './envelope-assembly.js';
|
|
17
|
+
import { deliverAndClaim, } from './delivery.js';
|
|
18
|
+
import { SkippableError } from '../types.js';
|
|
19
|
+
import { submitEvaluatorFeedback, codeDigestSha256ToBytes32, modeStringToFlag, } from '../../erc8004/index.js';
|
|
20
|
+
import { TrajectoryCollector, emitTrajectory } from '../../trajectory/index.js';
|
|
21
|
+
import { uploadToIpfs } from '../../adapters/mech/ipfs.js';
|
|
22
|
+
import { buildInfo } from '../../build-info.js';
|
|
23
|
+
import { getSolverNetContract } from '../../vendor/@jinn-network/sdk/dist/solvernets/index.js';
|
|
24
|
+
import { runHarnessWithFreezeFence, } from '../../daemon/freeze-fence.js';
|
|
25
|
+
import { harnessStateDirName } from '../names.js';
|
|
26
|
+
// ── Sentinel error ────────────────────────────────────────────────────────────
|
|
27
|
+
export class NotImplementedError extends Error {
|
|
28
|
+
transitionName;
|
|
29
|
+
constructor(transitionName) {
|
|
30
|
+
super(`[NotImplemented] ${transitionName} — fill in via subsequent task`);
|
|
31
|
+
this.name = 'NotImplementedError';
|
|
32
|
+
this.transitionName = transitionName;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Map task role to the operator role it requires in `joinedSolverNets`. */
|
|
36
|
+
function joinedRoleForTaskRole(taskRole) {
|
|
37
|
+
return taskRole === 'evaluation' ? 'evaluator' : 'solver';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build a `JoinedSolverNetsView` from the raw operator-config block.
|
|
41
|
+
*
|
|
42
|
+
* The config carries the full `JoinedSolverNetEntry` shape (manifestCid,
|
|
43
|
+
* name, roles, harness, model, plugins, ...). The engine only needs
|
|
44
|
+
* `roles` and the CID-keyed lookup, so this helper narrows it.
|
|
45
|
+
*/
|
|
46
|
+
export function joinedSolverNetsViewFromConfig(joined) {
|
|
47
|
+
if (!joined)
|
|
48
|
+
return undefined;
|
|
49
|
+
const map = new Map();
|
|
50
|
+
for (const [key, entry] of Object.entries(joined)) {
|
|
51
|
+
// The config keys joined nets by `manifestCid`. We accept either the key
|
|
52
|
+
// or the entry's `manifestCid` field; in practice they're identical.
|
|
53
|
+
const cid = entry.manifestCid ?? key;
|
|
54
|
+
map.set(cid, { roles: entry.roles });
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
get: (cid) => map.get(cid),
|
|
58
|
+
manifestCids: () => [...map.keys()],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// ── TaskEngine ─────────────────────────────────────────────────────────
|
|
62
|
+
export class TaskEngine {
|
|
63
|
+
persistence;
|
|
64
|
+
paths;
|
|
65
|
+
packagingDeps;
|
|
66
|
+
envelopeDeps;
|
|
67
|
+
deliveryDeps;
|
|
68
|
+
implRegistry;
|
|
69
|
+
solverNetRegistry;
|
|
70
|
+
joinedSolverNets;
|
|
71
|
+
manifestResolver;
|
|
72
|
+
identityPublisher;
|
|
73
|
+
reputationFeedback;
|
|
74
|
+
operatorConfig;
|
|
75
|
+
/**
|
|
76
|
+
* Operator-configured harness mode. Defaults to 'train' when absent.
|
|
77
|
+
* Propagated to HarnessContext.mode for each runImpl dispatch.
|
|
78
|
+
*/
|
|
79
|
+
harnessMode;
|
|
80
|
+
/** Local SQLite-backed store; used to emit `restoration-result` /
|
|
81
|
+
* `evaluation-verdict` artifact rows when a cycle completes via a
|
|
82
|
+
* deterministic impl (the legacy claude/MCP path writes them itself). */
|
|
83
|
+
store;
|
|
84
|
+
// Transient storage for impl output between runImpl and pack transitions.
|
|
85
|
+
// Keyed by requestId; cleared after successful pack.
|
|
86
|
+
solutionOutputs = new Map();
|
|
87
|
+
// Transient storage for the harness mode used during runImpl.
|
|
88
|
+
// Keyed by requestId; cleared after successful pack.
|
|
89
|
+
modesByRequest = new Map();
|
|
90
|
+
// Transient storage for the codeDigest returned by the freeze-fence.
|
|
91
|
+
// In train mode this is the post-run hash; in frozen mode it's the stable pre-hash.
|
|
92
|
+
// Keyed by requestId; cleared after successful pack.
|
|
93
|
+
codeDigestsByRequest = new Map();
|
|
94
|
+
// Transient storage for trajectory collectors produced in runImpl.
|
|
95
|
+
// emitTrajectory is deferred to pack() so that artifact spans can be added
|
|
96
|
+
// before the trajectory is finalised and uploaded (Task 16 bidirectional linkage).
|
|
97
|
+
// Keyed by requestId; cleared after successful pack.
|
|
98
|
+
// Protected (not private) to allow test subclasses to inject collectors.
|
|
99
|
+
trajectoryCollectors = new Map();
|
|
100
|
+
// Transient storage for trajectory CID+sha256 refs produced by runImpl.
|
|
101
|
+
// Keyed by requestId; cleared after successful pack.
|
|
102
|
+
trajectoryRefs = new Map();
|
|
103
|
+
runtimePluginsByRequest = new Map();
|
|
104
|
+
/** Set by stop(); causes runTickLoop to exit at the next iteration. */
|
|
105
|
+
stopped = false;
|
|
106
|
+
constructor(opts) {
|
|
107
|
+
this.persistence = new TaskRunPersistence(opts.store.db);
|
|
108
|
+
this.store = opts.store;
|
|
109
|
+
this.paths = opts.paths;
|
|
110
|
+
this.packagingDeps = opts.packagingDeps;
|
|
111
|
+
this.envelopeDeps = opts.envelopeDeps;
|
|
112
|
+
this.deliveryDeps = opts.deliveryDeps;
|
|
113
|
+
this.implRegistry = opts.implRegistry;
|
|
114
|
+
this.solverNetRegistry = opts.solverNetRegistry;
|
|
115
|
+
this.joinedSolverNets = opts.joinedSolverNets;
|
|
116
|
+
this.manifestResolver = opts.manifestResolver;
|
|
117
|
+
this.identityPublisher = opts.identityPublisher;
|
|
118
|
+
this.reputationFeedback = opts.reputationFeedback;
|
|
119
|
+
this.operatorConfig = opts.operatorConfig;
|
|
120
|
+
this.harnessMode = opts.harnessMode ?? 'train';
|
|
121
|
+
}
|
|
122
|
+
// ── Public API ──────────────────────────────────────────────────────────────
|
|
123
|
+
/**
|
|
124
|
+
* Called when an task is observed from an on-chain event.
|
|
125
|
+
* Persists a DISCOVERED row. Idempotent: if the row already exists, no-op.
|
|
126
|
+
*/
|
|
127
|
+
async observe(input) {
|
|
128
|
+
const existing = this.persistence.getByRequestId(input.requestId);
|
|
129
|
+
if (!existing) {
|
|
130
|
+
this.persistence.insertDiscovered(input);
|
|
131
|
+
console.log(`[harness-engine] observed task ${input.requestId} solverType=${input.solverType ?? 'null'}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async canAcceptTask(input) {
|
|
135
|
+
const reason = await this.runnableFailureReason(input.solverType, input.taskRole ?? 'restoration', input.task);
|
|
136
|
+
return reason ? { ok: false, reason } : { ok: true };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Recover all in-flight tasks from persisted state.
|
|
140
|
+
* Called at daemon startup before beginning normal event processing.
|
|
141
|
+
* Returns a per-task report for each task attempted.
|
|
142
|
+
*/
|
|
143
|
+
async recoverInFlight() {
|
|
144
|
+
const inflight = this.persistence.getInFlight();
|
|
145
|
+
const results = await Promise.allSettled(inflight.map((task) => this._recoverOne(task)));
|
|
146
|
+
const reports = results.map((result, i) => {
|
|
147
|
+
const requestId = inflight[i].requestId;
|
|
148
|
+
if (result.status === 'fulfilled') {
|
|
149
|
+
return { requestId, outcome: 'ok' };
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const error = result.reason instanceof Error
|
|
153
|
+
? result.reason.message
|
|
154
|
+
: String(result.reason);
|
|
155
|
+
return { requestId, outcome: 'failed', error };
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
const okCount = reports.filter((r) => r.outcome === 'ok').length;
|
|
159
|
+
console.log(`[harness-engine] recovery: ${okCount}/${reports.length} tasks resumed`);
|
|
160
|
+
return reports;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Periodic tick: advance every in-flight task by one transition.
|
|
164
|
+
* Called by `runTickLoop` so that tasks which entered a non-event-driven
|
|
165
|
+
* state (e.g. CLAIMED waiting for windowStartTs) get re-driven without
|
|
166
|
+
* waiting for a daemon restart or a fresh marketplace event.
|
|
167
|
+
*
|
|
168
|
+
* Errors from individual tasks are logged but do not stop the loop.
|
|
169
|
+
*/
|
|
170
|
+
async tick() {
|
|
171
|
+
const inflight = this.persistence.getInFlight();
|
|
172
|
+
const results = await Promise.allSettled(inflight.map((task) => this.process(task.requestId)));
|
|
173
|
+
for (let i = 0; i < results.length; i++) {
|
|
174
|
+
const r = results[i];
|
|
175
|
+
if (r.status === 'rejected') {
|
|
176
|
+
const requestId = inflight[i].requestId;
|
|
177
|
+
const reason = r.reason instanceof Error ? r.reason.message : String(r.reason);
|
|
178
|
+
console.warn(`[harness-engine] tick: process(${requestId}) failed: ${reason}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Drive `tick()` on a fixed interval until `stop()` is called.
|
|
184
|
+
* Errors thrown by tick() itself are logged and do not stop the loop.
|
|
185
|
+
*/
|
|
186
|
+
async runTickLoop(intervalMs) {
|
|
187
|
+
while (!this.stopped) {
|
|
188
|
+
try {
|
|
189
|
+
await this.tick();
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
console.error('[harness-engine] tick loop error (continuing):', err instanceof Error ? err.message : err);
|
|
193
|
+
}
|
|
194
|
+
if (this.stopped)
|
|
195
|
+
break;
|
|
196
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/** Signal `runTickLoop` to exit at the next iteration. */
|
|
200
|
+
stop() {
|
|
201
|
+
this.stopped = true;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Process a single task: dispatch by current state to the appropriate
|
|
205
|
+
* transition. Drives one state transition per call.
|
|
206
|
+
*
|
|
207
|
+
* Called both by recovery and by the ongoing event-processing loop.
|
|
208
|
+
*/
|
|
209
|
+
async process(requestId) {
|
|
210
|
+
const task = this.persistence.getByRequestId(requestId);
|
|
211
|
+
if (!task) {
|
|
212
|
+
throw new Error(`process: task not found: ${requestId}`);
|
|
213
|
+
}
|
|
214
|
+
switch (task.state) {
|
|
215
|
+
case TaskRunState.DISCOVERED:
|
|
216
|
+
await this._runTransition(task, () => this.claim(task));
|
|
217
|
+
break;
|
|
218
|
+
case TaskRunState.CLAIMED: {
|
|
219
|
+
// Advance to WAITING — persist-before-invoke principle.
|
|
220
|
+
const oldState = task.state;
|
|
221
|
+
this.persistence.transition(task.requestId, TaskRunState.WAITING);
|
|
222
|
+
console.log(`[harness-engine] ${requestId} ${oldState} → ${TaskRunState.WAITING}`);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case TaskRunState.WAITING: {
|
|
226
|
+
const advance = this.dataDrivenAdvance(task);
|
|
227
|
+
if (advance !== null) {
|
|
228
|
+
this.persistence.transition(task.requestId, advance);
|
|
229
|
+
console.log(`[harness-engine] ${requestId} ${task.state} → ${advance}`);
|
|
230
|
+
await this._runTransition(this.persistence.getOrThrow(requestId), () => this.takePreSnapshot(this.persistence.getOrThrow(requestId)));
|
|
231
|
+
// takePreSnapshot transitions PRE_SNAPSHOT → RUNNING. Re-dispatch on
|
|
232
|
+
// the post-transition state so RUNNING fires in the same pass (jinn-mono-sae).
|
|
233
|
+
const after = this.persistence.getByRequestId(task.requestId);
|
|
234
|
+
if (after && after.state === TaskRunState.RUNNING) {
|
|
235
|
+
await this.process(task.requestId);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// else: not yet time — caller is responsible for scheduling retry
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
case TaskRunState.PRE_SNAPSHOT: {
|
|
242
|
+
const advance = this.dataDrivenAdvance(task);
|
|
243
|
+
if (advance !== null) {
|
|
244
|
+
// Snapshot already captured (e.g. recovered from crash mid-transition)
|
|
245
|
+
this.persistence.transition(task.requestId, advance);
|
|
246
|
+
console.log(`[harness-engine] ${requestId} ${task.state} → ${advance}`);
|
|
247
|
+
await this._runTransition(this.persistence.getOrThrow(requestId), () => this.runImpl(this.persistence.getOrThrow(requestId)));
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
await this._runTransition(task, () => this.takePreSnapshot(task));
|
|
251
|
+
// takePreSnapshot transitions PRE_SNAPSHOT → RUNNING internally.
|
|
252
|
+
// Re-dispatch on the post-transition state so the RUNNING case fires
|
|
253
|
+
// in the same pass (jinn-mono-sae fix). Without this, tasks stall
|
|
254
|
+
// at RUNNING until the next tick/restart and runImpl never executes.
|
|
255
|
+
const after = this.persistence.getByRequestId(task.requestId);
|
|
256
|
+
if (after && after.state === TaskRunState.RUNNING) {
|
|
257
|
+
await this.process(task.requestId);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
case TaskRunState.RUNNING:
|
|
263
|
+
await this._runTransition(task, () => this.runImpl(task));
|
|
264
|
+
break;
|
|
265
|
+
case TaskRunState.POST_SNAPSHOT: {
|
|
266
|
+
const advance = this.dataDrivenAdvance(task);
|
|
267
|
+
if (advance !== null) {
|
|
268
|
+
this.persistence.transition(task.requestId, advance);
|
|
269
|
+
console.log(`[harness-engine] ${requestId} ${task.state} → ${advance}`);
|
|
270
|
+
await this._runTransition(this.persistence.getOrThrow(requestId), () => this.pack(this.persistence.getOrThrow(requestId)));
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
await this._runTransition(task, () => this.takePostSnapshot(task));
|
|
274
|
+
}
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
case TaskRunState.PACKAGING:
|
|
278
|
+
await this._runTransition(task, () => this.pack(task));
|
|
279
|
+
break;
|
|
280
|
+
case TaskRunState.DELIVERING:
|
|
281
|
+
await this._runTransition(task, () => this.deliver(task));
|
|
282
|
+
break;
|
|
283
|
+
case TaskRunState.COMPLETE:
|
|
284
|
+
case TaskRunState.FAILED:
|
|
285
|
+
// Terminal — nothing to do.
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// ── Transition stubs ────────────────────────────────────────────────────────
|
|
290
|
+
// Stubs throw NotImplementedError. claim() is implemented here; others are
|
|
291
|
+
// filled in by subsequent tasks.
|
|
292
|
+
/**
|
|
293
|
+
* TaskCoordinator clean-break claim transition.
|
|
294
|
+
*
|
|
295
|
+
* The on-chain Task claim happens before observe(), producing the internal
|
|
296
|
+
* Mech requestId stored in this row. The engine's CLAIM step now only verifies
|
|
297
|
+
* the operator has an enabled, ready Harness and advances DISCOVERED → CLAIMED.
|
|
298
|
+
*/
|
|
299
|
+
async claim(task) {
|
|
300
|
+
const reason = await this.runnableFailureReason(task.solverType ?? undefined, task.taskRole ?? 'restoration', task.task, task.requestId);
|
|
301
|
+
if (reason) {
|
|
302
|
+
this.persistence.markFailed(task.requestId, reason);
|
|
303
|
+
console.log(`[harness-engine] ${task.requestId}: skipping claimed task — ${reason}`);
|
|
304
|
+
throw new Error(reason);
|
|
305
|
+
}
|
|
306
|
+
// The event path and tick loop can race on the same DISCOVERED row; if
|
|
307
|
+
// another caller already advanced it, treat this as idempotent.
|
|
308
|
+
const current = this.persistence.getByRequestId(task.requestId);
|
|
309
|
+
if (!current) {
|
|
310
|
+
throw new Error(`claim: task not found after claim: ${task.requestId}`);
|
|
311
|
+
}
|
|
312
|
+
if (current.state === TaskRunState.DISCOVERED) {
|
|
313
|
+
this.persistence.transition(task.requestId, TaskRunState.CLAIMED);
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
console.log(`[harness-engine] ${task.requestId}: claim completed but state is already ${current.state}; skipping CLAIMED transition`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
async releaseClaimedNotStarted() {
|
|
320
|
+
// TaskCoordinator claims are made before observe(), so there is no
|
|
321
|
+
// recoverable "claimed but not started" engine row to release here.
|
|
322
|
+
return [];
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Internal routing key alias for the daemon-internal `solverType`-keyed
|
|
326
|
+
* harness map. Per spec §15 (non-goal of
|
|
327
|
+
* `spec/2026-05-05-solvernet-creation-and-launch.md`), the harness
|
|
328
|
+
* dispatch alias is intentionally retained for one cycle past Task 30;
|
|
329
|
+
* the user-facing surface (manifest, SPA, SDK shapes) is `solverType`-
|
|
330
|
+
* free. Prefers the canonical `${contractId}.${contractVersion}` when
|
|
331
|
+
* the task carries them, and falls back to the legacy `task.solverType`
|
|
332
|
+
* field for pre-Task-24 shapes / health-check tasks. Mirrors the SDK's
|
|
333
|
+
* internal `solverTypeAlias` helper but operates on a `Task`.
|
|
334
|
+
*/
|
|
335
|
+
routingKeyForTask(task, fallback) {
|
|
336
|
+
if (task?.contractId && task?.contractVersion) {
|
|
337
|
+
return `${task.contractId}.${task.contractVersion}`;
|
|
338
|
+
}
|
|
339
|
+
return task?.solverType ?? fallback;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Resolve the task's `solverNetManifestCid` via the registry, fetch the
|
|
343
|
+
* manifest, and validate the task body against `manifest.contract.schemas.task`.
|
|
344
|
+
*
|
|
345
|
+
* Returns `null` when validation passes (or is skipped because no
|
|
346
|
+
* `manifestResolver` is wired and the task carries no `solverNetManifestCid`),
|
|
347
|
+
* or a human-readable failure reason otherwise.
|
|
348
|
+
*
|
|
349
|
+
* Day-1 compatibility note: this validates via the SDK template's Zod schema
|
|
350
|
+
* looked up by `{contract.id, contract.version}`. The manifest's embedded
|
|
351
|
+
* JSON Schema is the canonical wire format; once external launchers can
|
|
352
|
+
* publish manifests with arbitrary task schemas, this will switch to a JSON
|
|
353
|
+
* Schema validator (or `jsonSchemaToZod`) over the manifest's own schema.
|
|
354
|
+
* See `spec/2026-05-05-solvernet-creation-and-launch.md` §14.
|
|
355
|
+
*/
|
|
356
|
+
async manifestBackedValidation(task) {
|
|
357
|
+
const cid = task.solverNetManifestCid;
|
|
358
|
+
if (!cid) {
|
|
359
|
+
// Without a manifest CID, schema validation can't run via the §14
|
|
360
|
+
// pipeline. Production callers (mech adapter) require CIDs at task
|
|
361
|
+
// post-time — this branch is hit only by tests / health-check tasks
|
|
362
|
+
// that don't exercise schema validation. The legacy
|
|
363
|
+
// `solverType`-keyed validation path was retired here.
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
if (!this.manifestResolver) {
|
|
367
|
+
// Engine wasn't constructed with a registry. Tests that don't exercise
|
|
368
|
+
// manifest resolution leave this unwired; treat schema validation as
|
|
369
|
+
// a no-op rather than failing — the daemon's production wiring always
|
|
370
|
+
// supplies a resolver.
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
let manifest;
|
|
374
|
+
try {
|
|
375
|
+
manifest = await this.manifestResolver.getManifest({ manifestCid: cid });
|
|
376
|
+
}
|
|
377
|
+
catch (err) {
|
|
378
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
379
|
+
return `manifest resolution failed for cid '${cid}': ${message}`;
|
|
380
|
+
}
|
|
381
|
+
const ref = { id: manifest.contract.id, version: manifest.contract.version };
|
|
382
|
+
// Defense against malformed task documents: if the task carries explicit
|
|
383
|
+
// `contractId`/`contractVersion`, they MUST agree with the manifest.
|
|
384
|
+
if (task.contractId !== undefined && task.contractId !== ref.id) {
|
|
385
|
+
return `task.contractId '${task.contractId}' does not match manifest contract.id '${ref.id}'`;
|
|
386
|
+
}
|
|
387
|
+
if (task.contractVersion !== undefined && task.contractVersion !== ref.version) {
|
|
388
|
+
return `task.contractVersion '${task.contractVersion}' does not match manifest contract.version '${ref.version}'`;
|
|
389
|
+
}
|
|
390
|
+
// Day-1 compatibility: validate via the SDK template's Zod for the
|
|
391
|
+
// resolved contract. Day-N (external launchers) will validate against
|
|
392
|
+
// `manifest.contract.schemas.task` directly via JSON Schema.
|
|
393
|
+
const sdkContract = getSolverNetContract(ref);
|
|
394
|
+
if (!sdkContract) {
|
|
395
|
+
return `unsupported contract '${ref.id}.${ref.version}' from manifest '${cid}'`;
|
|
396
|
+
}
|
|
397
|
+
const parsed = sdkContract.schemas.task.zod.safeParse(task);
|
|
398
|
+
if (!parsed.success) {
|
|
399
|
+
const parsedSpec = task.spec !== undefined
|
|
400
|
+
? sdkContract.schemas.task.zod.safeParse(task.spec)
|
|
401
|
+
: undefined;
|
|
402
|
+
if (parsedSpec?.success)
|
|
403
|
+
return null;
|
|
404
|
+
const specIssuesLookLikeWholeTask = parsedSpec !== undefined &&
|
|
405
|
+
parsedSpec.error.issues.some((issue) => {
|
|
406
|
+
const head = issue.path[0];
|
|
407
|
+
return typeof head === 'string' && ['id', 'description', 'solverType', 'window', 'claimPolicy', 'spec'].includes(head);
|
|
408
|
+
});
|
|
409
|
+
const selected = parsedSpec !== undefined && !specIssuesLookLikeWholeTask ? parsedSpec : parsed;
|
|
410
|
+
const issues = selected.error.issues
|
|
411
|
+
.map((issue) => `${issue.path.length > 0 ? issue.path.join('.') : '<root>'}: ${issue.message}`)
|
|
412
|
+
.join('; ');
|
|
413
|
+
const scope = selected === parsedSpec ? 'task.spec' : 'task';
|
|
414
|
+
return `${ref.id}.${ref.version} ${scope} failed validation: ${issues}`;
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Returns a human-readable failure reason when the task is NOT eligible
|
|
420
|
+
* for this operator under the manifest-bound per-launch attribution
|
|
421
|
+
* model (spec §14, Task 28), or `null` when the task passes the filter.
|
|
422
|
+
*
|
|
423
|
+
* Eligibility logic:
|
|
424
|
+
* - The operator must have an entry in `joinedSolverNets` whose
|
|
425
|
+
* `manifestCid` matches `task.solverNetManifestCid` (or whose
|
|
426
|
+
* `keccak256(manifestCid)` matches the task's on-chain
|
|
427
|
+
* `manifestDigest` when only the digest is available).
|
|
428
|
+
* - The entry's `roles` must include the role required by this task
|
|
429
|
+
* ('solver' for restoration, 'evaluator' for evaluation).
|
|
430
|
+
*
|
|
431
|
+
* Caller must have already guarded `this.joinedSolverNets` non-null and
|
|
432
|
+
* `task` non-null.
|
|
433
|
+
*/
|
|
434
|
+
evaluateJoinedEligibility(task, role) {
|
|
435
|
+
const view = this.joinedSolverNets;
|
|
436
|
+
const requiredRole = joinedRoleForTaskRole(role);
|
|
437
|
+
// Preferred path: the task body carries the manifest CID directly.
|
|
438
|
+
const cid = task.solverNetManifestCid;
|
|
439
|
+
if (cid) {
|
|
440
|
+
const entry = view.get(cid);
|
|
441
|
+
if (!entry) {
|
|
442
|
+
return (`task carries solverNetManifestCid '${cid}' but operator has not joined that SolverNet ` +
|
|
443
|
+
`(joinedSolverNets keys: [${view.manifestCids().join(', ') || '<empty>'}])`);
|
|
444
|
+
}
|
|
445
|
+
if (!entry.roles.includes(requiredRole)) {
|
|
446
|
+
return (`operator joined SolverNet '${cid}' but did not opt into role '${requiredRole}' ` +
|
|
447
|
+
`(roles: [${entry.roles.join(', ')}])`);
|
|
448
|
+
}
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
// Fallback path: task carries an on-chain `manifestDigest` (bytes32
|
|
452
|
+
// hex) without an off-chain CID. Compute keccak256 of every joined CID
|
|
453
|
+
// and compare. Used when the daemon discovers a task via on-chain
|
|
454
|
+
// event before fetching its IPFS body.
|
|
455
|
+
const taskRecord = task;
|
|
456
|
+
const taskDigest = taskRecord.manifestDigest;
|
|
457
|
+
if (taskDigest) {
|
|
458
|
+
const wantHex = taskDigest.toLowerCase();
|
|
459
|
+
for (const joinedCid of view.manifestCids()) {
|
|
460
|
+
const joinedDigest = keccak256(toBytes(joinedCid)).toLowerCase();
|
|
461
|
+
if (joinedDigest === wantHex) {
|
|
462
|
+
const entry = view.get(joinedCid);
|
|
463
|
+
if (!entry.roles.includes(requiredRole)) {
|
|
464
|
+
return (`operator joined SolverNet '${joinedCid}' but did not opt into role '${requiredRole}' ` +
|
|
465
|
+
`(roles: [${entry.roles.join(', ')}])`);
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return (`task manifestDigest '${taskDigest}' does not match any joined SolverNet ` +
|
|
471
|
+
`(joinedSolverNets keys: [${view.manifestCids().join(', ') || '<empty>'}])`);
|
|
472
|
+
}
|
|
473
|
+
// Task has neither solverNetManifestCid nor manifestDigest. Per spec §14,
|
|
474
|
+
// post-Task-24 task documents always carry a CID; absence here means a
|
|
475
|
+
// pre-migration / health-check / legacy task. We don't fail those — the
|
|
476
|
+
// legacy solverType-keyed gate downstream still runs.
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
async runnableFailureReason(solverType, role, task, currentRequestId) {
|
|
480
|
+
// Per-launch operator-eligibility filter (Task 28 of
|
|
481
|
+
// `spec/2026-05-05-solvernet-creation-and-launch.md` §14). When the
|
|
482
|
+
// operator has explicitly joined a set of SolverNets — keyed by the
|
|
483
|
+
// launched manifest's `manifestCid` — the engine refuses to accept any
|
|
484
|
+
// task whose on-chain `manifestDigest = keccak256(manifestCid)` doesn't
|
|
485
|
+
// match a joined entry, plus a role gate (restoration → 'solver',
|
|
486
|
+
// evaluation → 'evaluator'). This replaces the old protocol-level
|
|
487
|
+
// solverType filter and disambiguates Launcher A's Prediction from
|
|
488
|
+
// Launcher B's Prediction. The check is skipped when the engine has no
|
|
489
|
+
// `joinedSolverNets` view wired (legacy unit tests, in-memory adapter).
|
|
490
|
+
if (this.joinedSolverNets && task) {
|
|
491
|
+
const eligibility = this.evaluateJoinedEligibility(task, role);
|
|
492
|
+
if (eligibility)
|
|
493
|
+
return eligibility;
|
|
494
|
+
}
|
|
495
|
+
// Prefer the contract-derived routing alias when the task carries
|
|
496
|
+
// `contractId`/`contractVersion` (Task 24); fall back to the explicit
|
|
497
|
+
// `solverType` parameter for legacy pre-migration paths and PersistedTaskRun
|
|
498
|
+
// rows that pre-date `contractId`. See `routingKeyForTask`.
|
|
499
|
+
const routingKey = this.routingKeyForTask(task, solverType);
|
|
500
|
+
if (routingKey && this.persistence.hasInFlightFor({
|
|
501
|
+
solverType: routingKey,
|
|
502
|
+
taskRole: role,
|
|
503
|
+
excludeRequestId: currentRequestId,
|
|
504
|
+
})) {
|
|
505
|
+
return `another ${routingKey}/${role} task is already in flight`;
|
|
506
|
+
}
|
|
507
|
+
const solverNet = this.solverNetRegistry && routingKey
|
|
508
|
+
? this.solverNetRegistry.forSolverType(routingKey, role)
|
|
509
|
+
: undefined;
|
|
510
|
+
if (this.solverNetRegistry && routingKey && !solverNet) {
|
|
511
|
+
return `no enabled SolverNet for solverType '${routingKey}' and role '${role}'; run \`jinn solver-nets enable <name>\``;
|
|
512
|
+
}
|
|
513
|
+
if (task) {
|
|
514
|
+
// Per spec §14 of `spec/2026-05-05-solvernet-creation-and-launch.md`,
|
|
515
|
+
// task validation resolves manifest → contract → schemas:
|
|
516
|
+
// manifest = registry.getManifest({ manifestCid: task.solverNetManifestCid })
|
|
517
|
+
// contract = manifest.contract
|
|
518
|
+
// validateAgainstSchema(task, contract.schemas.task)
|
|
519
|
+
// The legacy `solverType`-keyed `validateTask(solverType, task)` path
|
|
520
|
+
// is retired here; the routing alias is recovered from
|
|
521
|
+
// `manifest.contract.{id, version}` for the harness map lookup
|
|
522
|
+
// (which still keys on the `<id>.<version>` string until Task 30).
|
|
523
|
+
const validationFailure = await this.manifestBackedValidation(task);
|
|
524
|
+
if (validationFailure)
|
|
525
|
+
return validationFailure;
|
|
526
|
+
}
|
|
527
|
+
if (!this.implRegistry || !routingKey)
|
|
528
|
+
return null;
|
|
529
|
+
const impl = this.implRegistry.findFor({ solverType: routingKey, role });
|
|
530
|
+
if (!impl) {
|
|
531
|
+
const setHarnessHint = solverNet
|
|
532
|
+
? `jinn solver-nets set-harness ${solverNet.name} <harness>`
|
|
533
|
+
: 'jinn solver-nets set-harness <name> <harness>';
|
|
534
|
+
return `no Harness registered or enabled for solverType '${routingKey}'; run \`${setHarnessHint}\``;
|
|
535
|
+
}
|
|
536
|
+
if (task) {
|
|
537
|
+
if (impl.canAttempt) {
|
|
538
|
+
const attempt = await impl.canAttempt(task);
|
|
539
|
+
if (!attempt.ok) {
|
|
540
|
+
return `impl '${impl.name}' cannot attempt task: ${attempt.reason}`;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
if (impl.isReady) {
|
|
545
|
+
const status = await impl.isReady({ solverType: routingKey, role });
|
|
546
|
+
if (!status.ready) {
|
|
547
|
+
return `impl '${impl.name}' not ready: ${status.reason ?? 'unknown'}${status.nextStep?.cli ? ` — run \`${status.nextStep.cli}\`` : ''}`;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* PRE_SNAPSHOT transition: provision workingDir + implStateDir, write
|
|
554
|
+
* task.json + env/ files, create sessions/ directory.
|
|
555
|
+
*
|
|
556
|
+
* Requires no external deps beyond filesystem access — always implemented.
|
|
557
|
+
* Advances state PRE_SNAPSHOT with workingDir + implStateDir patch.
|
|
558
|
+
*/
|
|
559
|
+
async takePreSnapshot(run) {
|
|
560
|
+
const workingDir = join(this.paths.workingDirRoot, run.requestId);
|
|
561
|
+
// Resolve the impl via registry so implStateDir matches the path runImpl uses
|
|
562
|
+
// (join(implStateDirRoot, impl.name, solverType)). Falls back to solverType then 'default'
|
|
563
|
+
// when no impl is registered — legacy path preserved for health-check tasks.
|
|
564
|
+
const resolvedImpl = run.solverType
|
|
565
|
+
? this.implRegistry?.findFor({ solverType: run.solverType, role: run.taskRole ?? 'restoration' }) ?? null
|
|
566
|
+
: null;
|
|
567
|
+
const implStateName = harnessStateDirName(run.implName ?? resolvedImpl?.name ?? run.solverType ?? 'default');
|
|
568
|
+
const kindSeg = (run.solverType ?? '').replace(/[.:]/g, '_');
|
|
569
|
+
const implStateDir = kindSeg
|
|
570
|
+
? join(this.paths.implStateDirRoot, implStateName, kindSeg)
|
|
571
|
+
: join(this.paths.implStateDirRoot, implStateName);
|
|
572
|
+
// Prefer the persisted full Task; fall back to a stub for legacy
|
|
573
|
+
// (pre-migration) rows so the engine still works for health-check tasks.
|
|
574
|
+
const task = run.task ?? {
|
|
575
|
+
id: run.requestId,
|
|
576
|
+
description: '',
|
|
577
|
+
...(run.solverType ? { solverType: run.solverType, spec: {} } : {}),
|
|
578
|
+
role: run.taskRole ?? 'restoration',
|
|
579
|
+
window: { startTs: run.windowStartTs, endTs: run.windowEndTs },
|
|
580
|
+
};
|
|
581
|
+
provisionWorkingDir(workingDir, task);
|
|
582
|
+
provisionImplStateDir(implStateDir);
|
|
583
|
+
// takePreSnapshot transitions directly to RUNNING with the snapshot payload
|
|
584
|
+
// and workingDir/implStateDir paths set. We cannot transition
|
|
585
|
+
// PRE_SNAPSHOT → PRE_SNAPSHOT (invalid); the snapshot is immediately ready
|
|
586
|
+
// (it's just the provisioned dir context), so we advance to RUNNING in one
|
|
587
|
+
// step. The impl is responsible for capturing real market data.
|
|
588
|
+
this.persistence.transition(run.requestId, TaskRunState.RUNNING, {
|
|
589
|
+
workingDir,
|
|
590
|
+
implStateDir,
|
|
591
|
+
preSnapshotCapturedAt: Date.now(),
|
|
592
|
+
preSnapshotPayload: { provisioned: true, workingDir },
|
|
593
|
+
});
|
|
594
|
+
console.log(`[harness-engine] ${run.requestId} PRE_SNAPSHOT -> RUNNING: workingDir=${workingDir}`);
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* RUNNING transition: dispatch to a Harness if implRegistry is provided.
|
|
598
|
+
*
|
|
599
|
+
* When no impl is found for the solverType, falls back to NotImplementedError
|
|
600
|
+
* so the engine does not silently swallow the request. In tests that don't
|
|
601
|
+
* exercise the impl path, override this method.
|
|
602
|
+
*
|
|
603
|
+
* Captures impl output in `solutionOutputs` map for pack() to consume. Also
|
|
604
|
+
* records a minimal post-snapshot so data-driven advance can fire.
|
|
605
|
+
*/
|
|
606
|
+
async runImpl(task) {
|
|
607
|
+
// The persisted `solver_type` column is authoritative for harness
|
|
608
|
+
// dispatch — it was derived at observation time from the canonical
|
|
609
|
+
// `${contractId}.${contractVersion}` alias (see Task 24's TaskCreated
|
|
610
|
+
// path). Internal routing key only — Task 30 retires the legacy
|
|
611
|
+
// string-keyed harness map.
|
|
612
|
+
const solverType = task.solverType ?? '';
|
|
613
|
+
const role = task.taskRole ?? 'restoration';
|
|
614
|
+
const solverNet = solverType ? this.solverNetRegistry?.forSolverType(solverType, role) : undefined;
|
|
615
|
+
const impl = this.implRegistry?.findFor({ solverType, role });
|
|
616
|
+
if (!impl) {
|
|
617
|
+
throw new NotImplementedError('runImpl');
|
|
618
|
+
}
|
|
619
|
+
const runtimePlugins = solverNet?.runtimePlugins ?? [];
|
|
620
|
+
this.runtimePluginsByRequest.set(task.requestId, runtimePlugins);
|
|
621
|
+
const workingDir = task.workingDir ?? join(this.paths.workingDirRoot, task.requestId);
|
|
622
|
+
const kindSeg = solverType.replace(/[.:]/g, '_');
|
|
623
|
+
const implStateDir = task.implStateDir ?? (kindSeg
|
|
624
|
+
? join(this.paths.implStateDirRoot, harnessStateDirName(impl.name), kindSeg)
|
|
625
|
+
: join(this.paths.implStateDirRoot, harnessStateDirName(impl.name)));
|
|
626
|
+
const windowEndTs = task.windowEndTs;
|
|
627
|
+
const abort = new AbortController();
|
|
628
|
+
const msUntilEndTs = () => Math.max(0, windowEndTs - Date.now());
|
|
629
|
+
const endTimer = setTimeout(() => abort.abort(), msUntilEndTs());
|
|
630
|
+
// Create a trajectory collector for this run.
|
|
631
|
+
const trajectory = new TrajectoryCollector({
|
|
632
|
+
taskCid: task.taskCid ?? '',
|
|
633
|
+
runId: randomUUID(),
|
|
634
|
+
});
|
|
635
|
+
try {
|
|
636
|
+
const ctx = {
|
|
637
|
+
task: (task.task ?? {
|
|
638
|
+
id: task.requestId,
|
|
639
|
+
description: '',
|
|
640
|
+
...(task.solverType ? { solverType: task.solverType, spec: {} } : {}),
|
|
641
|
+
role,
|
|
642
|
+
window: { startTs: task.windowStartTs, endTs: task.windowEndTs },
|
|
643
|
+
}),
|
|
644
|
+
requestId: task.requestId,
|
|
645
|
+
taskCid: task.taskCid,
|
|
646
|
+
solverNet: solverNet
|
|
647
|
+
? {
|
|
648
|
+
name: solverNet.name,
|
|
649
|
+
solverType: solverNet.solverType,
|
|
650
|
+
...(solverNet.model ? { model: solverNet.model } : {}),
|
|
651
|
+
}
|
|
652
|
+
: undefined,
|
|
653
|
+
runtimePlugins,
|
|
654
|
+
solverPluginRoots: runtimePlugins.map((plugin) => plugin.root),
|
|
655
|
+
implStateDir,
|
|
656
|
+
workingDir,
|
|
657
|
+
log: (event) => {
|
|
658
|
+
console.log(`[harness-impl:${impl.name}] [${event.level}] ${event.msg}`, event.data ?? '');
|
|
659
|
+
},
|
|
660
|
+
abort: abort.signal,
|
|
661
|
+
msUntilEndTs,
|
|
662
|
+
trajectory,
|
|
663
|
+
mode: this.harnessMode,
|
|
664
|
+
};
|
|
665
|
+
// Run the harness through the freeze-fence so frozen-mode violations
|
|
666
|
+
// are detected, rolled back, and surfaced as a structured event before
|
|
667
|
+
// envelope assembly (spec §6.3). SkippableError thrown by the harness
|
|
668
|
+
// will bubble out of the fence and be caught below.
|
|
669
|
+
let fence;
|
|
670
|
+
try {
|
|
671
|
+
fence = await runHarnessWithFreezeFence(impl, ctx);
|
|
672
|
+
}
|
|
673
|
+
catch (err) {
|
|
674
|
+
if (err instanceof SkippableError) {
|
|
675
|
+
const skippedAt = Date.now();
|
|
676
|
+
const detail = err.message;
|
|
677
|
+
console.warn(`[harness-engine] ${task.requestId}: impl=${impl.name} skipped (${err.reason}): ${detail}`);
|
|
678
|
+
const skippedOutput = {
|
|
679
|
+
venueRef: { name: 'legacy' },
|
|
680
|
+
gating: {
|
|
681
|
+
skipped: true,
|
|
682
|
+
reason: err.reason,
|
|
683
|
+
skippedAt: String(skippedAt),
|
|
684
|
+
},
|
|
685
|
+
informational: {
|
|
686
|
+
status: 'skipped',
|
|
687
|
+
detail,
|
|
688
|
+
},
|
|
689
|
+
artifacts: [],
|
|
690
|
+
};
|
|
691
|
+
this.solutionOutputs.set(task.requestId, skippedOutput);
|
|
692
|
+
this.modesByRequest.set(task.requestId, ctx.mode);
|
|
693
|
+
// Preserve trajectory for downstream pack() access (Task 6 regression fix).
|
|
694
|
+
this.trajectoryCollectors.set(task.requestId, trajectory);
|
|
695
|
+
// No codeDigest for skipped runs — leave map empty.
|
|
696
|
+
// Fall through to persistence below via goto-equivalent pattern.
|
|
697
|
+
this.persistence.transition(task.requestId, TaskRunState.POST_SNAPSHOT, {
|
|
698
|
+
postSnapshotCapturedAt: Date.now(),
|
|
699
|
+
postSnapshotPayload: { capturedAt: Date.now(), hlTime: 0, payload: null },
|
|
700
|
+
fillsPayload: [],
|
|
701
|
+
gatingClaim: skippedOutput.gating,
|
|
702
|
+
informationalClaim: skippedOutput.informational ?? null,
|
|
703
|
+
solutionOutputsJson: JSON.stringify(skippedOutput),
|
|
704
|
+
implName: impl.name,
|
|
705
|
+
runtimePluginsJson: JSON.stringify(runtimePlugins),
|
|
706
|
+
});
|
|
707
|
+
console.log(`[harness-engine] ${task.requestId} RUNNING → POST_SNAPSHOT via impl=${impl.name} (skipped)`);
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
throw err;
|
|
711
|
+
}
|
|
712
|
+
if (!fence.ok) {
|
|
713
|
+
// Violation: the harness mutated implStateDir in frozen mode.
|
|
714
|
+
// Snapshot already restored by the fence. Emit a structured log,
|
|
715
|
+
// skip envelope assembly, and mark the task FAILED.
|
|
716
|
+
ctx.log({
|
|
717
|
+
level: 'error',
|
|
718
|
+
msg: 'Harness violated frozen-mode contract — envelope rejected',
|
|
719
|
+
data: fence.violation,
|
|
720
|
+
});
|
|
721
|
+
this.persistence.markFailed(task.requestId, `freeze-fence violation: implStateDir mutated in frozen mode (harness=${fence.violation.harnessName}@${fence.violation.harnessVersion})`);
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
// Store the codeDigest from the fence (post-run hash in train mode;
|
|
725
|
+
// stable pre-hash in frozen mode) for use in pack().
|
|
726
|
+
this.codeDigestsByRequest.set(task.requestId, `sha256:${fence.codeDigest}`);
|
|
727
|
+
this.modesByRequest.set(task.requestId, ctx.mode);
|
|
728
|
+
const output = fence.output;
|
|
729
|
+
this.solutionOutputs.set(task.requestId, output);
|
|
730
|
+
// Store the trajectory collector so pack() can:
|
|
731
|
+
// 1. pass it to uploadArtifacts (artifact.emit spans + producedBy metadata)
|
|
732
|
+
// 2. call emitTrajectory AFTER artifact upload so spans are included
|
|
733
|
+
// 3. backfill trajectoryCid on artifacts before envelope assembly
|
|
734
|
+
// emitTrajectory is intentionally deferred to pack() (Task 16).
|
|
735
|
+
this.trajectoryCollectors.set(task.requestId, trajectory);
|
|
736
|
+
// Persist impl output BEFORE the state transition so that a crash after
|
|
737
|
+
// the transition (RUNNING → POST_SNAPSHOT) but before pack() runs will
|
|
738
|
+
// find the serialised output in the DB on restart. pack() will hydrate the
|
|
739
|
+
// in-memory map from solutionOutputsJson if the map entry is absent (#6).
|
|
740
|
+
// Capture post-snapshot from impl output so data-driven advance fires
|
|
741
|
+
this.persistence.transition(task.requestId, TaskRunState.POST_SNAPSHOT, {
|
|
742
|
+
postSnapshotCapturedAt: Date.now(),
|
|
743
|
+
postSnapshotPayload: output.postSnapshot ?? { capturedAt: Date.now(), hlTime: 0, payload: null },
|
|
744
|
+
fillsPayload: output.fills ?? [],
|
|
745
|
+
gatingClaim: output.gating,
|
|
746
|
+
informationalClaim: output.informational ?? null,
|
|
747
|
+
solutionOutputsJson: JSON.stringify(output),
|
|
748
|
+
implName: impl.name,
|
|
749
|
+
runtimePluginsJson: JSON.stringify(runtimePlugins),
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
finally {
|
|
753
|
+
clearTimeout(endTimer);
|
|
754
|
+
}
|
|
755
|
+
console.log(`[harness-engine] ${task.requestId} RUNNING → POST_SNAPSHOT via impl=${impl.name}`);
|
|
756
|
+
}
|
|
757
|
+
async takePostSnapshot(_intent) {
|
|
758
|
+
throw new NotImplementedError('takePostSnapshot');
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* PACKAGING transition: walk workingDir, upload artifacts, assemble + sign
|
|
762
|
+
* envelope, upload envelope, persist envelope CID + artifact CIDs.
|
|
763
|
+
*
|
|
764
|
+
* Requires packagingDeps + envelopeDeps. When absent, falls back to
|
|
765
|
+
* NotImplementedError.
|
|
766
|
+
*/
|
|
767
|
+
async pack(task) {
|
|
768
|
+
// Hydrate implOutput from DB if the in-memory map was lost (e.g. process restart
|
|
769
|
+
// after RUNNING → POST_SNAPSHOT but before pack() completed). This must run
|
|
770
|
+
// BEFORE the packagingDeps guard so subclass overrides that call super.pack()
|
|
771
|
+
// can still benefit from hydration even when packagingDeps is absent (#6).
|
|
772
|
+
if (!this.solutionOutputs.has(task.requestId) && task.solutionOutputsJson != null) {
|
|
773
|
+
try {
|
|
774
|
+
const recovered = JSON.parse(task.solutionOutputsJson);
|
|
775
|
+
this.solutionOutputs.set(task.requestId, recovered);
|
|
776
|
+
console.log(`[harness-engine] ${task.requestId}: hydrated solutionOutputs from DB (crash recovery)`);
|
|
777
|
+
}
|
|
778
|
+
catch (err) {
|
|
779
|
+
console.warn(`[harness-engine] ${task.requestId}: failed to hydrate solutionOutputsJson: ${err instanceof Error ? err.message : err}`);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
if (!this.packagingDeps || !this.envelopeDeps) {
|
|
783
|
+
throw new NotImplementedError('pack');
|
|
784
|
+
}
|
|
785
|
+
const workingDir = task.workingDir ?? join(this.paths.workingDirRoot, task.requestId);
|
|
786
|
+
const implOutput = this.solutionOutputs.get(task.requestId);
|
|
787
|
+
const implArtifacts = implOutput?.artifacts ?? [];
|
|
788
|
+
// 1. Walk + upload artifacts (NO registration yet — manifest CID not known).
|
|
789
|
+
// Pass the trajectory collector (if present) so uploadArtifacts can emit
|
|
790
|
+
// jinn.artifact.emit spans and attach producedBy back-refs (Task 16 forward
|
|
791
|
+
// linkage). emitTrajectory is called AFTER upload so artifact spans are included.
|
|
792
|
+
const collector = this.trajectoryCollectors.get(task.requestId);
|
|
793
|
+
const packagingDepsWithReq = {
|
|
794
|
+
...this.packagingDeps,
|
|
795
|
+
requestId: task.requestId,
|
|
796
|
+
...(collector ? { collector } : {}),
|
|
797
|
+
};
|
|
798
|
+
const rawArtifacts = await walkArtifacts(workingDir, implArtifacts, packagingDepsWithReq.donation?.enabled
|
|
799
|
+
? { scrub: packagingDepsWithReq.donation.scrub }
|
|
800
|
+
: {});
|
|
801
|
+
const uploadedArtifacts = await uploadArtifacts(rawArtifacts, packagingDepsWithReq);
|
|
802
|
+
// 1b. Emit trajectory to IPFS now that all artifact spans have been added.
|
|
803
|
+
// Non-fatal — envelope assembly continues with envelope.trajectory = null if upload fails.
|
|
804
|
+
let trajectoryRef = this.trajectoryRefs.get(task.requestId) ?? null;
|
|
805
|
+
if (!trajectoryRef && collector && this.envelopeDeps) {
|
|
806
|
+
try {
|
|
807
|
+
const { privateKeyToAccount } = await import('viem/accounts');
|
|
808
|
+
const account = privateKeyToAccount(this.envelopeDeps.agentEoaPrivateKey);
|
|
809
|
+
const { cid, sha256, signed } = await emitTrajectory({
|
|
810
|
+
collector,
|
|
811
|
+
runId: collector.runId,
|
|
812
|
+
signerPrivateKey: this.envelopeDeps.agentEoaPrivateKey,
|
|
813
|
+
signerAddress: account.address,
|
|
814
|
+
ipfsRegistryUrl: this.envelopeDeps.ipfsRegistryUrl,
|
|
815
|
+
scrub: packagingDepsWithReq.donation?.scrub,
|
|
816
|
+
});
|
|
817
|
+
const sources = [];
|
|
818
|
+
if (packagingDepsWithReq.donation?.enabled) {
|
|
819
|
+
const sourceCid = await uploadToIpfs(packagingDepsWithReq.donation.ipfsRegistryUrl, {
|
|
820
|
+
schemaVersion: DONATION_ARTIFACT_ENCODING,
|
|
821
|
+
artifactType: 'jinn.trajectory.v1',
|
|
822
|
+
sha256,
|
|
823
|
+
encoding: DONATION_ARTIFACT_ENCODING,
|
|
824
|
+
data: Buffer.from(JSON.stringify(signed), 'utf8').toString('base64'),
|
|
825
|
+
});
|
|
826
|
+
sources.push({
|
|
827
|
+
kind: 'ipfs',
|
|
828
|
+
cid: sourceCid,
|
|
829
|
+
sha256,
|
|
830
|
+
encoding: DONATION_ARTIFACT_ENCODING,
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
trajectoryRef = { cid, sha256, ...(sources.length > 0 ? { sources } : {}) };
|
|
834
|
+
console.log(`[harness-engine] ${task.requestId}: trajectory emitted cid=${cid}`);
|
|
835
|
+
}
|
|
836
|
+
catch (err) {
|
|
837
|
+
console.warn(`[harness-engine] ${task.requestId}: trajectory emit failed (non-fatal):`, err instanceof Error ? err.message : err);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
this.trajectoryRefs.set(task.requestId, trajectoryRef);
|
|
841
|
+
// 1c. Backward linkage: backfill trajectoryCid on all artifacts that have a
|
|
842
|
+
// producedBy back-ref. This must happen BEFORE assembleAndSignEnvelope so the
|
|
843
|
+
// signed envelope carries the complete reference (Task 16).
|
|
844
|
+
if (trajectoryRef) {
|
|
845
|
+
const trajectoryCid = trajectoryRef.cid;
|
|
846
|
+
for (const art of uploadedArtifacts) {
|
|
847
|
+
const pb = art.metadata?.['producedBy'];
|
|
848
|
+
if (pb != null && typeof pb === 'object' && 'spanId' in pb) {
|
|
849
|
+
pb['trajectoryCid'] = trajectoryCid;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
// Map to Artifact shape (strip localPath)
|
|
854
|
+
const artifacts = uploadedArtifacts.map(({ localPath: _localPath, ...art }) => art);
|
|
855
|
+
// 2. Derive agentEoa from private key
|
|
856
|
+
const { privateKeyToAccount } = await import('viem/accounts');
|
|
857
|
+
const account = privateKeyToAccount(this.envelopeDeps.agentEoaPrivateKey);
|
|
858
|
+
const agentEoa = account.address;
|
|
859
|
+
// Safe multisig address — sourced from envelopeDeps (preferred) or deliveryDeps.
|
|
860
|
+
// Hard throw if absent: falling back to agentEoa would produce a
|
|
861
|
+
// protocol-invalid envelope (safeAddress MUST differ from agentEoa, §5.1).
|
|
862
|
+
const safeAddress = this.envelopeDeps.safeAddress ?? this.deliveryDeps?.safeAddress;
|
|
863
|
+
if (!safeAddress) {
|
|
864
|
+
throw new Error('pack: safeAddress not configured in envelopeDeps or deliveryDeps');
|
|
865
|
+
}
|
|
866
|
+
// 3. Build envelope payload from impl output (kind-typed, wrapped into payload field)
|
|
867
|
+
const preSnapshotPayload = task.preSnapshotPayload;
|
|
868
|
+
const postSnapshotPayload = task.postSnapshotPayload;
|
|
869
|
+
// The solverType drives payload schema selection. Fall back to 'legacy.v0'
|
|
870
|
+
// for tasks without a solverType (legacy health-check / daemon-loop-test
|
|
871
|
+
// tasks that use the legacy-claude impl). The legacy.v0 kind accepts any
|
|
872
|
+
// Record payload so validatePayload does not reject the output.
|
|
873
|
+
const solverType = task.solverType ?? 'legacy.v0';
|
|
874
|
+
// Derive role from Task.role. Evaluator tasks produce 'verdict' envelopes;
|
|
875
|
+
// all other tasks produce 'restoration' envelopes.
|
|
876
|
+
const isEvaluation = task.taskRole === 'evaluation';
|
|
877
|
+
const role = isEvaluation ? 'verdict' : 'restoration';
|
|
878
|
+
let envelopePayload;
|
|
879
|
+
if (isEvaluation) {
|
|
880
|
+
// ── Verdict envelope payload ──────────────────────────────────────────────
|
|
881
|
+
// The evaluator impl populates verdictPayload on Solution with a
|
|
882
|
+
// PortfolioV0VerdictPayload-shaped object. Engine passes it through to the
|
|
883
|
+
// envelope assembler, which runs validatePayload('portfolio.v0', 'verdict', ...).
|
|
884
|
+
//
|
|
885
|
+
// If verdictPayload is absent (impl bug / crash recovery), fall back to a
|
|
886
|
+
// minimal INDETERMINATE stub so the envelope assembly does not silently succeed
|
|
887
|
+
// with a wrong shape — validatePayload will catch schema mismatches.
|
|
888
|
+
//
|
|
889
|
+
// verificationOfRestoration: stubbed — Plan D will connect the real SDK.
|
|
890
|
+
// restorationEnvelope.sha256: placeholder — Plan D wires real sha256 derivation.
|
|
891
|
+
const verdictPayload = implOutput?.verdictPayload;
|
|
892
|
+
if (!verdictPayload) {
|
|
893
|
+
throw new Error(`pack: evaluator impl for ${task.requestId} did not produce verdictPayload on Solution; ` +
|
|
894
|
+
`ensure the impl populates output.verdictPayload`);
|
|
895
|
+
}
|
|
896
|
+
// If the (stub) verificationOfRestoration reports 'invalid', downgrade verdict
|
|
897
|
+
// to REJECTED per scope §3.3. For V1 the stub always returns 'valid', so this
|
|
898
|
+
// path does not fire in practice — Plan D makes it real.
|
|
899
|
+
const verif = verdictPayload['verificationOfRestoration'];
|
|
900
|
+
if (verif?.overall === 'invalid') {
|
|
901
|
+
// Override verdict to REJECTED; preserve the rest of the payload.
|
|
902
|
+
envelopePayload = {
|
|
903
|
+
...verdictPayload,
|
|
904
|
+
verdict: 'REJECTED',
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
envelopePayload = verdictPayload;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
else if (implOutput?.solutionPayload) {
|
|
912
|
+
// ── Non-portfolio restoration envelope payload ────────────────────────────
|
|
913
|
+
// Impls for kinds with a non-portfolio payload schema (e.g. prediction.v1)
|
|
914
|
+
// declare their own fully-formed payload. Engine passes it through directly
|
|
915
|
+
// so validatePayload() can check it against the per-kind schema.
|
|
916
|
+
envelopePayload = implOutput.solutionPayload;
|
|
917
|
+
}
|
|
918
|
+
else {
|
|
919
|
+
// ── Portfolio restoration envelope payload (legacy / portfolio.v0) ─────────
|
|
920
|
+
envelopePayload = {
|
|
921
|
+
preSnapshot: {
|
|
922
|
+
capturedAt: task.preSnapshotCapturedAt ?? Date.now(),
|
|
923
|
+
hlTime: preSnapshotPayload?.hlTime ?? 0,
|
|
924
|
+
// Double-fallback: first tries the structured .payload field (normal shape),
|
|
925
|
+
// then falls back to the whole payload object (handles takePreSnapshot's
|
|
926
|
+
// synthetic shape where the snapshot IS the top-level object, not nested).
|
|
927
|
+
payload: preSnapshotPayload?.payload ?? preSnapshotPayload ?? {},
|
|
928
|
+
},
|
|
929
|
+
postSnapshot: {
|
|
930
|
+
capturedAt: task.postSnapshotCapturedAt ?? Date.now(),
|
|
931
|
+
hlTime: postSnapshotPayload?.hlTime ?? 0,
|
|
932
|
+
// Same double-fallback as above.
|
|
933
|
+
payload: postSnapshotPayload?.payload ?? postSnapshotPayload ?? {},
|
|
934
|
+
},
|
|
935
|
+
fills: task.fillsPayload ?? [],
|
|
936
|
+
gating: task.gatingClaim ?? {},
|
|
937
|
+
...(task.informationalClaim != null
|
|
938
|
+
? { informational: task.informationalClaim }
|
|
939
|
+
: {}),
|
|
940
|
+
...(implOutput?.rationale != null ? { rationale: implOutput.rationale } : {}),
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
// 4. Persist generatedAt once (first pack); reuse on retry for CID determinism.
|
|
944
|
+
const generatedAt = task.manifestGeneratedAt ?? Date.now();
|
|
945
|
+
if (!task.manifestGeneratedAt) {
|
|
946
|
+
// Persist before assembling so that a crash after assembly but before
|
|
947
|
+
// transition still gets the same generatedAt on the next attempt.
|
|
948
|
+
this.persistence.setManifestGeneratedAt(task.requestId, generatedAt);
|
|
949
|
+
}
|
|
950
|
+
// 5. Assemble + sign envelope → envelope CID now known.
|
|
951
|
+
// trajectoryRef was computed in step 1b above (emitted after artifact upload).
|
|
952
|
+
// Per the post-gating-fix schema, trajectory references carry sha256 + access
|
|
953
|
+
// (the operator HTTP endpoint that serves the bytes). Phase 3 (jinn-mono-vy37.1.3)
|
|
954
|
+
// sources this from the engine's operatorConfig; absent operatorConfig (e.g. test
|
|
955
|
+
// fixtures) falls back to packagingDeps.operatorEndpoint, then to a localhost
|
|
956
|
+
// sentinel so suites that don't exercise the publish path still pack cleanly.
|
|
957
|
+
const operatorEndpointForTraj = this.operatorConfig?.publicEndpoint
|
|
958
|
+
?? this.packagingDeps?.operatorEndpoint
|
|
959
|
+
?? 'http://localhost:7331';
|
|
960
|
+
const envelopeTrajectory = trajectoryRef
|
|
961
|
+
? {
|
|
962
|
+
sha256: trajectoryRef.sha256,
|
|
963
|
+
access: { endpoint: operatorEndpointForTraj, priceUsdc: '0' },
|
|
964
|
+
...(trajectoryRef.sources && trajectoryRef.sources.length > 0
|
|
965
|
+
? { sources: trajectoryRef.sources }
|
|
966
|
+
: {}),
|
|
967
|
+
}
|
|
968
|
+
: null;
|
|
969
|
+
// evidenceTier reflects the on-chain commitment state at the time of signing.
|
|
970
|
+
// For the V2 claim flow, claimDelivery will write an evidenceHash on-chain,
|
|
971
|
+
// so the envelope should be declared 'committed'. For V1 or unknown flows,
|
|
972
|
+
// 'self-signed' is accurate (no on-chain hash commitment).
|
|
973
|
+
const evidenceTier = this.deliveryDeps?.claimDeliveryVariant === 'v2' || this.deliveryDeps?.claimDeliveryVariant === 'v3'
|
|
974
|
+
? 'committed'
|
|
975
|
+
: 'self-signed';
|
|
976
|
+
const runtimePlugins = this.runtimePluginsByRequest.get(task.requestId)
|
|
977
|
+
?? (task.runtimePluginsJson ? JSON.parse(task.runtimePluginsJson) : []);
|
|
978
|
+
const executorPlugins = runtimePlugins
|
|
979
|
+
.map((plugin) => ({
|
|
980
|
+
name: plugin.name,
|
|
981
|
+
version: plugin.version,
|
|
982
|
+
...(plugin.cid ? { cid: plugin.cid } : {}),
|
|
983
|
+
sha256: plugin.sha256,
|
|
984
|
+
}))
|
|
985
|
+
.sort((a, b) => `${a.name}@${a.version}`.localeCompare(`${b.name}@${b.version}`));
|
|
986
|
+
const implNameForEnvelope = task.implName ?? solverType;
|
|
987
|
+
const solverNet = solverType
|
|
988
|
+
? this.solverNetRegistry?.forSolverType(solverType, task.taskRole ?? 'restoration')
|
|
989
|
+
: undefined;
|
|
990
|
+
const runtimeBundleDigest = `sha256:${createHash('sha256')
|
|
991
|
+
.update(JSON.stringify({
|
|
992
|
+
harness: {
|
|
993
|
+
name: implNameForEnvelope,
|
|
994
|
+
version: buildInfo.implVersion,
|
|
995
|
+
codeDigest: buildInfo.codeDigest,
|
|
996
|
+
},
|
|
997
|
+
solverNet: solverNet ? { name: solverNet.name, solverType: solverNet.solverType } : null,
|
|
998
|
+
plugins: executorPlugins,
|
|
999
|
+
}))
|
|
1000
|
+
.digest('hex')}`;
|
|
1001
|
+
// Resolve the mode and codeDigest from the in-memory maps populated by
|
|
1002
|
+
// runImpl. Defaults: mode = 'train' (backward compat), codeDigest from
|
|
1003
|
+
// buildInfo (fallback when runImpl did not run through the fence, e.g.
|
|
1004
|
+
// crash-recovery from solutionOutputsJson without a fresh runImpl).
|
|
1005
|
+
const executorMode = this.modesByRequest.get(task.requestId) ?? 'train';
|
|
1006
|
+
const fenceCodeDigest = this.codeDigestsByRequest.get(task.requestId) ?? buildInfo.codeDigest;
|
|
1007
|
+
const envelopeInputs = {
|
|
1008
|
+
solverType,
|
|
1009
|
+
role,
|
|
1010
|
+
task: {
|
|
1011
|
+
cid: task.taskCid,
|
|
1012
|
+
onchainCreationTx: task.onchainCreationTx,
|
|
1013
|
+
onchainCreationBlock: task.onchainCreationBlock,
|
|
1014
|
+
requestId: task.requestId,
|
|
1015
|
+
},
|
|
1016
|
+
participant: { safeAddress, agentEoa },
|
|
1017
|
+
window: { startTs: task.windowStartTs, endTs: task.windowEndTs },
|
|
1018
|
+
executor: {
|
|
1019
|
+
implName: implNameForEnvelope,
|
|
1020
|
+
// buildInfo resolves to real values in production builds; falls back to
|
|
1021
|
+
// clearly-labelled placeholders ('dev' / 'sha256:dev-build') when running
|
|
1022
|
+
// via tsx without a prior `yarn build` (dev mode).
|
|
1023
|
+
implVersion: buildInfo.implVersion,
|
|
1024
|
+
clientGitSha: buildInfo.clientGitSha,
|
|
1025
|
+
codeDigest: fenceCodeDigest,
|
|
1026
|
+
runtimeBundleDigest,
|
|
1027
|
+
plugins: executorPlugins,
|
|
1028
|
+
signingKey: { kind: 'agent-eoa', pubkey: agentEoa },
|
|
1029
|
+
// Propagate the harness execution mode (train | frozen) so the
|
|
1030
|
+
// envelope records whether implStateDir was locked during this run.
|
|
1031
|
+
mode: executorMode,
|
|
1032
|
+
},
|
|
1033
|
+
evidenceTier,
|
|
1034
|
+
trajectory: envelopeTrajectory,
|
|
1035
|
+
artifacts,
|
|
1036
|
+
payload: envelopePayload,
|
|
1037
|
+
generatedAt,
|
|
1038
|
+
};
|
|
1039
|
+
const { envelopeCid, envelopeHash } = await assembleAndSignEnvelope(envelopeInputs, this.envelopeDeps);
|
|
1040
|
+
const manifestCid = envelopeCid;
|
|
1041
|
+
const signatureHash = envelopeHash;
|
|
1042
|
+
// 6. ERC-8004 IdentityRegistry per-execution `setMetadata` fires in
|
|
1043
|
+
// deliver() AFTER claimDelivery succeeds. 'committed' must mean
|
|
1044
|
+
// "observable on-chain evidenceHash exists" — publishing before claim
|
|
1045
|
+
// would lie during failures. The evidenceHash (signatureHash) is
|
|
1046
|
+
// persisted to DELIVERING state below and reused by deliver().
|
|
1047
|
+
// Operator-rooted entity model: docs/superpowers/specs/2026-04-27-erc-8004-entity-model-design.md.
|
|
1048
|
+
// 7. Build artifact sha256 map for persistence.
|
|
1049
|
+
// Post-gating-fix (spec §1): artifacts no longer have IPFS CIDs — bytes
|
|
1050
|
+
// live in served_artifacts keyed by sha256. We reuse the legacy
|
|
1051
|
+
// `artifactCids` persistence column (key: localPath) but populate it with
|
|
1052
|
+
// sha256 hashes so downstream readers still get a stable identifier.
|
|
1053
|
+
const artifactCids = {};
|
|
1054
|
+
for (const art of uploadedArtifacts) {
|
|
1055
|
+
artifactCids[art.localPath] = art.sha256;
|
|
1056
|
+
}
|
|
1057
|
+
// Backfill envelope_cid (manifestCid) on every served_artifacts row so
|
|
1058
|
+
// the operator can answer manifest-rooted lookups later. Done after the
|
|
1059
|
+
// manifest CID is known.
|
|
1060
|
+
for (const art of uploadedArtifacts) {
|
|
1061
|
+
this.store.setServedArtifactEnvelopeCid(art.sha256, manifestCid);
|
|
1062
|
+
}
|
|
1063
|
+
// 8. Persist DELIVERING with manifest CID + artifact CIDs + evidence hash.
|
|
1064
|
+
// evidenceHash gets its own dedicated column (not stashed in informationalClaim).
|
|
1065
|
+
// executorMode + executorCodeDigest are also persisted so deliver() can
|
|
1066
|
+
// emit a payload v2 setMetadata after the transient maps are cleared.
|
|
1067
|
+
// See `client/src/erc8004/identity.ts` (publishContentV2) and the
|
|
1068
|
+
// payload-v2 ABI tuple in `abis.ts`.
|
|
1069
|
+
this.persistence.transition(task.requestId, TaskRunState.DELIVERING, {
|
|
1070
|
+
manifestCid,
|
|
1071
|
+
artifactCids,
|
|
1072
|
+
evidenceHash: signatureHash,
|
|
1073
|
+
executorMode,
|
|
1074
|
+
executorCodeDigest: fenceCodeDigest,
|
|
1075
|
+
});
|
|
1076
|
+
console.log(`[harness-engine] ${task.requestId} PACKAGING → DELIVERING manifestCid=${manifestCid}`);
|
|
1077
|
+
// Clean up transient state (no longer needed after DELIVERING)
|
|
1078
|
+
this.solutionOutputs.delete(task.requestId);
|
|
1079
|
+
this.trajectoryCollectors.delete(task.requestId);
|
|
1080
|
+
this.trajectoryRefs.delete(task.requestId);
|
|
1081
|
+
this.modesByRequest.delete(task.requestId);
|
|
1082
|
+
this.codeDigestsByRequest.delete(task.requestId);
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* DELIVERING transition: call mech.deliverToMarketplace + JinnRouter.claimDelivery.
|
|
1086
|
+
*
|
|
1087
|
+
* Requires deliveryDeps. When absent, falls back to NotImplementedError.
|
|
1088
|
+
*
|
|
1089
|
+
* Crash-recovery safe: if `task.deliveryTxHash` is already set (persisted
|
|
1090
|
+
* after a previous deliverToMarketplace call that completed before the process
|
|
1091
|
+
* crashed), we skip the deliver step and go straight to claimDelivery.
|
|
1092
|
+
*/
|
|
1093
|
+
async deliver(task) {
|
|
1094
|
+
if (!this.deliveryDeps) {
|
|
1095
|
+
throw new NotImplementedError('deliver');
|
|
1096
|
+
}
|
|
1097
|
+
const manifestCid = task.manifestCid;
|
|
1098
|
+
if (!manifestCid) {
|
|
1099
|
+
throw new Error(`deliver: manifestCid missing for ${task.requestId}`);
|
|
1100
|
+
}
|
|
1101
|
+
// Guard: v2 claimDelivery requires an evidenceHash — a zero fallback would
|
|
1102
|
+
// silently brick staking rewards, so we fail loudly instead.
|
|
1103
|
+
const evidenceHash = task.evidenceHash;
|
|
1104
|
+
if (!evidenceHash && (this.deliveryDeps.claimDeliveryVariant === 'v2' || this.deliveryDeps.claimDeliveryVariant === 'v3')) {
|
|
1105
|
+
throw new MissingEvidenceHashError(task.requestId);
|
|
1106
|
+
}
|
|
1107
|
+
// Capture locals for use in the onDeliveryTxLanded closure.
|
|
1108
|
+
const requestId = task.requestId;
|
|
1109
|
+
const persistence = this.persistence;
|
|
1110
|
+
const { deliveryTxHash, claimTxHash } = await deliverAndClaim(requestId, manifestCid, evidenceHash, this.deliveryDeps,
|
|
1111
|
+
// Recovery: pass existing deliveryTxHash so deliverToMarketplace is skipped.
|
|
1112
|
+
task.deliveryTxHash ?? undefined,
|
|
1113
|
+
// Persist deliveryTxHash before claimDelivery so recovery can resume from here.
|
|
1114
|
+
async (txHash) => {
|
|
1115
|
+
persistence.setDeliveryTxHash(requestId, txHash);
|
|
1116
|
+
}, {
|
|
1117
|
+
kind: task.taskRole === 'evaluation' ? 'verdict' : 'solution',
|
|
1118
|
+
verdictCode: task.taskRole === 'evaluation' ? this.verdictCodeForTask(task) : undefined,
|
|
1119
|
+
});
|
|
1120
|
+
this.persistence.transition(requestId, TaskRunState.COMPLETE, {
|
|
1121
|
+
deliveryTxHash,
|
|
1122
|
+
});
|
|
1123
|
+
console.log(`[harness-engine] ${requestId} DELIVERING → COMPLETE deliveryTx=${deliveryTxHash} claimTx=${claimTxHash}`);
|
|
1124
|
+
// Emit a SQLite artifact row so consumers (release acceptance gate, search
|
|
1125
|
+
// API) see this cycle alongside legacy-claude / MCP-emitted rows. The
|
|
1126
|
+
// legacy claude path writes via the MCP `submit_restoration_result` tool;
|
|
1127
|
+
// deterministic impls (prediction.v1 baseline/evaluator,
|
|
1128
|
+
// …) don't go through MCP, so the engine emits on their behalf here.
|
|
1129
|
+
// Idempotent: skips when a row for this requestId+tag already exists
|
|
1130
|
+
// (legacy path may have already inserted).
|
|
1131
|
+
this.emitCycleArtifact(task, manifestCid, evidenceHash);
|
|
1132
|
+
// ── ERC-8004 setMetadata — fires AFTER claimDelivery succeeds ────────────
|
|
1133
|
+
//
|
|
1134
|
+
// Moved here from pack() per PR#37 review2 must-fix #2. 'committed' means
|
|
1135
|
+
// "observable on-chain evidenceHash exists" — publishing before claim would
|
|
1136
|
+
// lie during failures. evidenceHash comes from task (persisted in
|
|
1137
|
+
// DELIVERING state by pack()); idempotent on retry (setMetadata is a pure
|
|
1138
|
+
// key-value write; re-running with the same payload is safe).
|
|
1139
|
+
//
|
|
1140
|
+
// Restoration-only for now. Evaluator setMetadata lands with jinn-mono-2ff.
|
|
1141
|
+
if (this.identityPublisher) {
|
|
1142
|
+
const taskRoleRaw = task.taskRole ?? 'restoration';
|
|
1143
|
+
if (taskRoleRaw === 'restoration') {
|
|
1144
|
+
const signatureHash = evidenceHash;
|
|
1145
|
+
// v0 tier rule: with an evidenceHash on chain we declare `committed` (tier=1);
|
|
1146
|
+
// higher tiers (`attested`, `proved`) come later when TEE work lands.
|
|
1147
|
+
const tier = signatureHash ? 1 : 0;
|
|
1148
|
+
const manifestHashHex = signatureHash ?? '0x';
|
|
1149
|
+
// Prefer v2 when the harness identity is available — the engine
|
|
1150
|
+
// captures executorMode + executorCodeDigest in pack(). For legacy
|
|
1151
|
+
// rows that completed before payload v2 wiring (or for solver paths
|
|
1152
|
+
// that don't produce a fence digest), executorCodeDigest is null and
|
|
1153
|
+
// we fall back to the v1 encoder so the indexer still sees envelope
|
|
1154
|
+
// metadata, just without harness identity. v1 envelopes are decoded
|
|
1155
|
+
// by the subgraph as mode='train' with empty codeDigest/implName.
|
|
1156
|
+
const harnessImplName = task.implName;
|
|
1157
|
+
const canEmitV2 = !!task.executorMode &&
|
|
1158
|
+
!!task.executorCodeDigest &&
|
|
1159
|
+
!!harnessImplName;
|
|
1160
|
+
try {
|
|
1161
|
+
let pubTxHash;
|
|
1162
|
+
if (canEmitV2) {
|
|
1163
|
+
const v2Payload = {
|
|
1164
|
+
version: 2,
|
|
1165
|
+
tier,
|
|
1166
|
+
manifestHash: manifestHashHex,
|
|
1167
|
+
attestationQuoteCid: '0x',
|
|
1168
|
+
sourceMeasurement: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1169
|
+
codeDigest: codeDigestSha256ToBytes32(task.executorCodeDigest),
|
|
1170
|
+
implName: harnessImplName,
|
|
1171
|
+
modeFlag: modeStringToFlag(task.executorMode),
|
|
1172
|
+
};
|
|
1173
|
+
pubTxHash = await this.identityPublisher.publishContentV2({
|
|
1174
|
+
kind: 'envelope',
|
|
1175
|
+
cid: manifestCid,
|
|
1176
|
+
payload: v2Payload,
|
|
1177
|
+
});
|
|
1178
|
+
console.log(`[harness-engine] ${requestId}: setMetadata envelope:${manifestCid} tx=${pubTxHash} (payload v2 mode=${task.executorMode} impl=${harnessImplName})`);
|
|
1179
|
+
}
|
|
1180
|
+
else {
|
|
1181
|
+
const v1Payload = {
|
|
1182
|
+
version: 1,
|
|
1183
|
+
tier,
|
|
1184
|
+
manifestHash: manifestHashHex,
|
|
1185
|
+
attestationQuoteCid: '0x',
|
|
1186
|
+
sourceMeasurement: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1187
|
+
};
|
|
1188
|
+
pubTxHash = await this.identityPublisher.publishContent({
|
|
1189
|
+
kind: 'envelope',
|
|
1190
|
+
cid: manifestCid,
|
|
1191
|
+
payload: v1Payload,
|
|
1192
|
+
});
|
|
1193
|
+
console.log(`[harness-engine] ${requestId}: setMetadata envelope:${manifestCid} tx=${pubTxHash} (payload v1)`);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
catch (err) {
|
|
1197
|
+
console.warn(`[harness-engine] ${requestId}: setMetadata envelope publish failed (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
// ── Reputation feedback hook (jinn-mono-yg4) ─────────────────────────────
|
|
1202
|
+
//
|
|
1203
|
+
// Evaluator-only path: after `claimDelivery` settles the verdict, fire
|
|
1204
|
+
// `ReputationRegistry.giveFeedback(harnessAgentId, ...)` so the
|
|
1205
|
+
// harness's agent NFT accrues a rating (DR §4.3).
|
|
1206
|
+
//
|
|
1207
|
+
// Best-effort: any failure inside the hook is logged but does not
|
|
1208
|
+
// change the COMPLETE state. claimDelivery is already authoritative.
|
|
1209
|
+
if (task.taskRole === 'evaluation' && this.reputationFeedback) {
|
|
1210
|
+
await this._maybePostEvaluatorFeedback(task).catch((err) => {
|
|
1211
|
+
console.warn(`[harness-engine] ${requestId}: reputation feedback hook errored unexpectedly (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Post evaluator feedback on the harness's agent NFT.
|
|
1217
|
+
*
|
|
1218
|
+
* Pulls the verdict from the persisted gating claim (the evaluator impl
|
|
1219
|
+
* writes `{ verdict, score, scoreBasis, ... }` into `output.gating`),
|
|
1220
|
+
* resolves the harness's `agentId` via the configured subgraph
|
|
1221
|
+
* resolver, and submits a single `ReputationRegistry.giveFeedback` tx.
|
|
1222
|
+
*
|
|
1223
|
+
* Skipped silently when:
|
|
1224
|
+
* - No `reputationFeedback` deps wired.
|
|
1225
|
+
* - `gatingClaim` doesn't carry a verdict (impl shape mismatch — log and
|
|
1226
|
+
* return).
|
|
1227
|
+
* - The parent harness's manifest hash isn't reachable from the
|
|
1228
|
+
* persisted state — log and return).
|
|
1229
|
+
* - `resolveAgentId` returns null (subgraph not indexed yet, or no
|
|
1230
|
+
* subgraph URL configured at all — log and return).
|
|
1231
|
+
*
|
|
1232
|
+
* The mapping policy (PASS / FAIL / REJECTED / INDETERMINATE → score) lives
|
|
1233
|
+
* inside `submitEvaluatorFeedback` / `mapVerdictToScore` in the
|
|
1234
|
+
* feedback-hook module; we just hand it the verdict.
|
|
1235
|
+
*/
|
|
1236
|
+
/**
|
|
1237
|
+
* Insert a SQLite `artifacts` row for a successfully delivered cycle so the
|
|
1238
|
+
* release acceptance gate (and the search API) can observe completion via
|
|
1239
|
+
* the same surface as the legacy claude / MCP path.
|
|
1240
|
+
*
|
|
1241
|
+
* The legacy `legacy-claude` impl writes via the MCP `submit_restoration_result`
|
|
1242
|
+
* tool when Claude reports success; deterministic impls don't go through MCP.
|
|
1243
|
+
* This emitter closes that gap by writing the row from the engine when the
|
|
1244
|
+
* cycle hits COMPLETE.
|
|
1245
|
+
*
|
|
1246
|
+
* Idempotent: if a row already exists for (requestId, tag) — e.g. the legacy
|
|
1247
|
+
* MCP path got there first — we leave it alone.
|
|
1248
|
+
*/
|
|
1249
|
+
emitCycleArtifact(task, manifestCid, evidenceHash) {
|
|
1250
|
+
const taskId = task.task?.id;
|
|
1251
|
+
if (!taskId) {
|
|
1252
|
+
// Rows without task payload cannot be attributed to a Task id. Skip
|
|
1253
|
+
// rather than synthesise provenance.
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
const taskRole = task.taskRole ?? 'restoration';
|
|
1257
|
+
const tag = taskRole === 'evaluation' ? 'evaluation-verdict' : 'restoration-result';
|
|
1258
|
+
const existing = this.store.getArtifactByRequestId(task.requestId, tag);
|
|
1259
|
+
if (existing)
|
|
1260
|
+
return;
|
|
1261
|
+
this.store.insertArtifact({
|
|
1262
|
+
id: randomUUID(),
|
|
1263
|
+
taskId,
|
|
1264
|
+
requestId: task.requestId,
|
|
1265
|
+
title: `${tag}: ${task.solverType ?? 'cycle'} (${task.implName ?? 'engine'})`,
|
|
1266
|
+
content: JSON.stringify({
|
|
1267
|
+
manifestCid,
|
|
1268
|
+
evidenceHash: evidenceHash ?? null,
|
|
1269
|
+
implName: task.implName,
|
|
1270
|
+
}),
|
|
1271
|
+
tags: [tag, 'success'],
|
|
1272
|
+
outcome: 'SUCCESS',
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
verdictCodeForTask(task) {
|
|
1276
|
+
const gating = task.gatingClaim;
|
|
1277
|
+
const raw = gating?.verdict;
|
|
1278
|
+
switch (raw) {
|
|
1279
|
+
case 'PASS':
|
|
1280
|
+
case 'SCORED':
|
|
1281
|
+
return 1;
|
|
1282
|
+
case 'FAIL':
|
|
1283
|
+
case 'REJECTED':
|
|
1284
|
+
return 2;
|
|
1285
|
+
case 'INVALID':
|
|
1286
|
+
return 3;
|
|
1287
|
+
case 'INDETERMINATE':
|
|
1288
|
+
case 'UNRESOLVED':
|
|
1289
|
+
return 4;
|
|
1290
|
+
default:
|
|
1291
|
+
return 1;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
async _maybePostEvaluatorFeedback(task) {
|
|
1295
|
+
if (!this.reputationFeedback)
|
|
1296
|
+
return;
|
|
1297
|
+
const gating = task.gatingClaim;
|
|
1298
|
+
const verdictRaw = gating?.['verdict'];
|
|
1299
|
+
if (verdictRaw !== 'PASS' &&
|
|
1300
|
+
verdictRaw !== 'FAIL' &&
|
|
1301
|
+
verdictRaw !== 'REJECTED' &&
|
|
1302
|
+
verdictRaw !== 'INDETERMINATE') {
|
|
1303
|
+
console.warn(`[harness-engine] ${task.requestId}: reputation feedback skipped — gatingClaim has no recognised verdict (got=${String(verdictRaw)})`);
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
const verdict = verdictRaw;
|
|
1307
|
+
// Pull the parent harness's manifest evidence from the inlined eval
|
|
1308
|
+
// payload. The evaluator impl receives the harness's signed manifest
|
|
1309
|
+
// JSON via `task.context.restorationResult`. Its `signature.hash` is
|
|
1310
|
+
// exactly what the harness committed via `claimDelivery(evidenceHash)`.
|
|
1311
|
+
const parent = this._extractHarnessManifestRef(task);
|
|
1312
|
+
if (!parent) {
|
|
1313
|
+
console.warn(`[harness-engine] ${task.requestId}: reputation feedback skipped — could not extract harness manifest hash from inlined evaluation payload`);
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
let resolved;
|
|
1317
|
+
try {
|
|
1318
|
+
resolved = await this.reputationFeedback.resolveAgentId(parent.evidenceHash);
|
|
1319
|
+
}
|
|
1320
|
+
catch (err) {
|
|
1321
|
+
console.warn(`[harness-engine] ${task.requestId}: reputation feedback resolver threw (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
if (!resolved) {
|
|
1325
|
+
console.log(`[harness-engine] ${task.requestId}: reputation feedback skipped — no agentId resolved for harness manifestHash=${parent.evidenceHash} (subgraph not indexed yet, or no envelope published)`);
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
// CID resolution priority: subgraph row's `manifestCid` (cheapest, the
|
|
1329
|
+
// operator already published an envelope under it), else the inlined
|
|
1330
|
+
// CID hint when present, else fall back to the bare hash. The subgraph
|
|
1331
|
+
// parses `manifest:<cid>` to a `manifestRef` regardless.
|
|
1332
|
+
const manifestCid = resolved.manifestCid ?? parent.manifestCid ?? '';
|
|
1333
|
+
// The SolverType is the same value used by the restoration —
|
|
1334
|
+
// `task.solverType` is "portfolio.v0" both for the restoration and its
|
|
1335
|
+
// evaluation. Tag1 is indexed on the on-chain event, so cheap to filter.
|
|
1336
|
+
const kind = task.solverType ?? undefined;
|
|
1337
|
+
const verdictArg = kind ? { verdict, solverType: kind } : { verdict };
|
|
1338
|
+
let outcome;
|
|
1339
|
+
try {
|
|
1340
|
+
outcome = await submitEvaluatorFeedback({
|
|
1341
|
+
registry: this.reputationFeedback.client,
|
|
1342
|
+
ref: {
|
|
1343
|
+
harnessAgentId: resolved.agentId,
|
|
1344
|
+
harnessManifestCid: manifestCid,
|
|
1345
|
+
harnessEvidenceHash: parent.evidenceHash,
|
|
1346
|
+
},
|
|
1347
|
+
verdict: verdictArg,
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
catch (err) {
|
|
1351
|
+
// submitEvaluatorFeedback already swallows known reverts, but a
|
|
1352
|
+
// truly unexpected throw still must not propagate past delivery.
|
|
1353
|
+
console.warn(`[harness-engine] ${task.requestId}: reputation feedback unexpected throw (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
console.log(`[harness-engine] ${task.requestId}: reputation feedback ${outcome.kind} verdict=${verdict} harnessAgentId=${resolved.agentId.toString()}`);
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Extract the harness's `evidenceHash` (and best-effort `manifestCid`)
|
|
1360
|
+
* from the persisted evaluation task.
|
|
1361
|
+
*
|
|
1362
|
+
* The evaluator's `task.context.restorationResult` holds the harness's
|
|
1363
|
+
* full signed manifest JSON inlined as a string. We parse it and pull the
|
|
1364
|
+
* `signature.hash`, which is exactly the on-chain `evidenceHash`.
|
|
1365
|
+
*
|
|
1366
|
+
* The CID is not always inlined — the manifest carries its own
|
|
1367
|
+
* `task.cid` field (the *original task* CID), not its self-CID. We
|
|
1368
|
+
* therefore return `manifestCid: null` here and rely on the subgraph
|
|
1369
|
+
* resolver to surface the published manifest CID. Returns `null` when
|
|
1370
|
+
* the inlined payload is missing or malformed.
|
|
1371
|
+
*/
|
|
1372
|
+
_extractHarnessManifestRef(task) {
|
|
1373
|
+
const ds = task.task;
|
|
1374
|
+
const inlined = ds?.context?.['restorationResult'];
|
|
1375
|
+
if (typeof inlined !== 'string' || inlined.length === 0) {
|
|
1376
|
+
return null;
|
|
1377
|
+
}
|
|
1378
|
+
let parsed;
|
|
1379
|
+
try {
|
|
1380
|
+
parsed = JSON.parse(inlined);
|
|
1381
|
+
}
|
|
1382
|
+
catch {
|
|
1383
|
+
return null;
|
|
1384
|
+
}
|
|
1385
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
1386
|
+
return null;
|
|
1387
|
+
}
|
|
1388
|
+
const sig = parsed['signature'];
|
|
1389
|
+
if (typeof sig !== 'object' || sig === null) {
|
|
1390
|
+
return null;
|
|
1391
|
+
}
|
|
1392
|
+
const hashRaw = sig['hash'];
|
|
1393
|
+
if (typeof hashRaw !== 'string' || !/^0x[0-9a-fA-F]{64}$/.test(hashRaw)) {
|
|
1394
|
+
return null;
|
|
1395
|
+
}
|
|
1396
|
+
return {
|
|
1397
|
+
evidenceHash: hashRaw,
|
|
1398
|
+
manifestCid: null,
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
// ── Internal helpers ────────────────────────────────────────────────────────
|
|
1402
|
+
/**
|
|
1403
|
+
* Returns the next state if the current state can be advanced purely from
|
|
1404
|
+
* persisted data (no external work needed), or null if external work is required.
|
|
1405
|
+
*
|
|
1406
|
+
* Used for crash recovery and for collapsing transitions in process()
|
|
1407
|
+
* when a previous run already produced the data.
|
|
1408
|
+
*/
|
|
1409
|
+
dataDrivenAdvance(task) {
|
|
1410
|
+
switch (task.state) {
|
|
1411
|
+
case TaskRunState.WAITING:
|
|
1412
|
+
return Date.now() >= task.windowStartTs ? TaskRunState.PRE_SNAPSHOT : null;
|
|
1413
|
+
case TaskRunState.PRE_SNAPSHOT:
|
|
1414
|
+
return task.preSnapshotPayload != null ? TaskRunState.RUNNING : null;
|
|
1415
|
+
case TaskRunState.POST_SNAPSHOT:
|
|
1416
|
+
return task.postSnapshotPayload != null ? TaskRunState.PACKAGING : null;
|
|
1417
|
+
default:
|
|
1418
|
+
return null;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Wraps a transition method call with error handling: if the transition
|
|
1423
|
+
* throws, the task is marked FAILED with the error message.
|
|
1424
|
+
*/
|
|
1425
|
+
async _runTransition(task, fn) {
|
|
1426
|
+
const oldState = task.state;
|
|
1427
|
+
try {
|
|
1428
|
+
await fn();
|
|
1429
|
+
const updated = this.persistence.getByRequestId(task.requestId);
|
|
1430
|
+
if (updated && updated.state !== oldState) {
|
|
1431
|
+
console.log(`[harness-engine] ${task.requestId} ${oldState} → ${updated.state}`);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
catch (err) {
|
|
1435
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1436
|
+
this.persistence.markFailed(task.requestId, reason);
|
|
1437
|
+
throw err;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Recovery handler for a single in-flight task.
|
|
1442
|
+
* Dispatches by state per §6.5.
|
|
1443
|
+
*/
|
|
1444
|
+
async _recoverOne(task) {
|
|
1445
|
+
try {
|
|
1446
|
+
await this._recoverDispatch(task);
|
|
1447
|
+
}
|
|
1448
|
+
catch (err) {
|
|
1449
|
+
// If recovery itself throws (e.g. NotImplementedError stub), mark failed.
|
|
1450
|
+
// NotImplementedError is expected during development; don't swallow it in prod.
|
|
1451
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1452
|
+
// Only mark failed if the task is still in the same non-terminal state
|
|
1453
|
+
// (another concurrent recovery pass might have already advanced it).
|
|
1454
|
+
const current = this.persistence.getByRequestId(task.requestId);
|
|
1455
|
+
if (current && current.state === task.state) {
|
|
1456
|
+
this.persistence.markFailed(task.requestId, `recovery: ${reason}`);
|
|
1457
|
+
console.error(`[harness-engine] resume failed for ${task.requestId}: ${reason}`);
|
|
1458
|
+
}
|
|
1459
|
+
throw err;
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Per-state recovery dispatch per §6.5.
|
|
1464
|
+
*/
|
|
1465
|
+
async _recoverDispatch(task) {
|
|
1466
|
+
switch (task.state) {
|
|
1467
|
+
case TaskRunState.DISCOVERED:
|
|
1468
|
+
// Ready to claim — delegate to claim flow (subsequent task).
|
|
1469
|
+
// Stub: leaves state unchanged; logs task is ready.
|
|
1470
|
+
await this.claim(task);
|
|
1471
|
+
break;
|
|
1472
|
+
case TaskRunState.CLAIMED:
|
|
1473
|
+
// Advance to WAITING — no side effect needed.
|
|
1474
|
+
this.persistence.transition(task.requestId, TaskRunState.WAITING);
|
|
1475
|
+
await this._recoverDispatch(this.persistence.getOrThrow(task.requestId));
|
|
1476
|
+
break;
|
|
1477
|
+
case TaskRunState.WAITING: {
|
|
1478
|
+
const advance = this.dataDrivenAdvance(task);
|
|
1479
|
+
if (advance !== null) {
|
|
1480
|
+
// Window has started — advance immediately.
|
|
1481
|
+
this.persistence.transition(task.requestId, advance);
|
|
1482
|
+
await this._recoverDispatch(this.persistence.getOrThrow(task.requestId));
|
|
1483
|
+
}
|
|
1484
|
+
// else: schedule a timer for startTs — caller handles scheduling.
|
|
1485
|
+
break;
|
|
1486
|
+
}
|
|
1487
|
+
case TaskRunState.PRE_SNAPSHOT: {
|
|
1488
|
+
const advance = this.dataDrivenAdvance(task);
|
|
1489
|
+
if (advance !== null) {
|
|
1490
|
+
// Snapshot already in DB — advance to RUNNING.
|
|
1491
|
+
this.persistence.transition(task.requestId, advance);
|
|
1492
|
+
await this._recoverDispatch(this.persistence.getOrThrow(task.requestId));
|
|
1493
|
+
}
|
|
1494
|
+
else {
|
|
1495
|
+
// Need to (re-)fetch snapshot.
|
|
1496
|
+
await this.takePreSnapshot(task);
|
|
1497
|
+
// takePreSnapshot transitions PRE_SNAPSHOT → RUNNING. Re-dispatch
|
|
1498
|
+
// against the post-transition state so runImpl actually fires for
|
|
1499
|
+
// tasks that were persisted at CLAIMED/WAITING/PRE_SNAPSHOT
|
|
1500
|
+
// before a restart (otherwise recovery stops at RUNNING-but-not-run).
|
|
1501
|
+
const after = this.persistence.getByRequestId(task.requestId);
|
|
1502
|
+
if (after && after.state !== task.state && after.state !== TaskRunState.FAILED) {
|
|
1503
|
+
await this._recoverDispatch(after);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
break;
|
|
1507
|
+
}
|
|
1508
|
+
case TaskRunState.RUNNING:
|
|
1509
|
+
// Re-spawn impl with workingDir + implStateDir intact.
|
|
1510
|
+
await this.runImpl(task);
|
|
1511
|
+
break;
|
|
1512
|
+
case TaskRunState.POST_SNAPSHOT: {
|
|
1513
|
+
const advance = this.dataDrivenAdvance(task);
|
|
1514
|
+
if (advance !== null) {
|
|
1515
|
+
// Snapshot already in DB — advance to PACKAGING.
|
|
1516
|
+
this.persistence.transition(task.requestId, advance);
|
|
1517
|
+
await this._recoverDispatch(this.persistence.getOrThrow(task.requestId));
|
|
1518
|
+
}
|
|
1519
|
+
else {
|
|
1520
|
+
await this.takePostSnapshot(task);
|
|
1521
|
+
}
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1524
|
+
case TaskRunState.PACKAGING:
|
|
1525
|
+
// Re-walk workingDir + Solution; re-upload missing CIDs.
|
|
1526
|
+
await this.pack(task);
|
|
1527
|
+
break;
|
|
1528
|
+
case TaskRunState.DELIVERING:
|
|
1529
|
+
// Chain query — if already delivered → COMPLETE; else retry.
|
|
1530
|
+
await this.deliver(task);
|
|
1531
|
+
break;
|
|
1532
|
+
case TaskRunState.COMPLETE:
|
|
1533
|
+
case TaskRunState.FAILED:
|
|
1534
|
+
// Terminal — nothing to recover.
|
|
1535
|
+
break;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
// ── runHarnessOnce ────────────────────────────────────────────────────────────
|
|
1540
|
+
/**
|
|
1541
|
+
* Thin, test-friendly entry point for the freeze-fence + mode propagation
|
|
1542
|
+
* path. Runs a single `harness.run(ctx)` call through `runHarnessWithFreezeFence`
|
|
1543
|
+
* and returns either a minimal envelope stub (carrying `executor.mode`) or a
|
|
1544
|
+
* structured violation result — without requiring a full DB-backed TaskEngine
|
|
1545
|
+
* state machine.
|
|
1546
|
+
*
|
|
1547
|
+
* This function is *not* the production dispatch path; it exists so integration
|
|
1548
|
+
* tests can drive the mode-propagation and freeze-fence behaviour in isolation.
|
|
1549
|
+
*
|
|
1550
|
+
* @returns
|
|
1551
|
+
* `{ envelope: { executor: { mode } } }` on success.
|
|
1552
|
+
* `{ violation: FreezeViolation }` when the fence rejects the harness output.
|
|
1553
|
+
*
|
|
1554
|
+
* Spec: docs/superpowers/specs/2026-05-06-agent-harness-solvernet-design.md §6.3
|
|
1555
|
+
*/
|
|
1556
|
+
export async function runHarnessOnce(params) {
|
|
1557
|
+
const { harness, implStateDir, mode } = params;
|
|
1558
|
+
const workingDir = params.workingDir ?? implStateDir;
|
|
1559
|
+
const task = params.task ?? {
|
|
1560
|
+
id: 'test-task',
|
|
1561
|
+
description: '',
|
|
1562
|
+
role: 'restoration',
|
|
1563
|
+
window: { startTs: 0, endTs: Date.now() + 3_600_000 },
|
|
1564
|
+
};
|
|
1565
|
+
const ctx = {
|
|
1566
|
+
task,
|
|
1567
|
+
implStateDir,
|
|
1568
|
+
workingDir,
|
|
1569
|
+
log: () => { },
|
|
1570
|
+
abort: new AbortController().signal,
|
|
1571
|
+
msUntilEndTs: () => Math.max(0, (task.window?.endTs ?? Date.now() + 3_600_000) - Date.now()),
|
|
1572
|
+
trajectory: new TrajectoryCollector({ taskCid: '', runId: 'test-run' }),
|
|
1573
|
+
mode,
|
|
1574
|
+
};
|
|
1575
|
+
const fence = await runHarnessWithFreezeFence(harness, ctx);
|
|
1576
|
+
if (!fence.ok) {
|
|
1577
|
+
return { violation: fence.violation };
|
|
1578
|
+
}
|
|
1579
|
+
return {
|
|
1580
|
+
envelope: {
|
|
1581
|
+
executor: {
|
|
1582
|
+
mode,
|
|
1583
|
+
codeDigest: `sha256:${fence.codeDigest}`,
|
|
1584
|
+
},
|
|
1585
|
+
},
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
//# sourceMappingURL=engine.js.map
|