@jinn-network/client 0.1.7 → 0.1.8-canary.0a152013
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/README.md +67 -1
- package/dist/adapters/mech/adapter.d.ts +19 -1
- package/dist/adapters/mech/adapter.js +130 -14
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +22 -1
- package/dist/adapters/mech/contracts.js +34 -24
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/safe.d.ts +1 -1
- package/dist/adapters/mech/safe.js +5 -3
- package/dist/adapters/mech/safe.js.map +1 -1
- package/dist/adapters/mech/types.d.ts +6 -1
- package/dist/adapters/mech/types.js.map +1 -1
- package/dist/agent/operator-claude.js +8 -0
- package/dist/agent/operator-claude.js.map +1 -1
- package/dist/api/activity-events-endpoint.d.ts +14 -0
- package/dist/api/activity-events-endpoint.js +59 -0
- package/dist/api/activity-events-endpoint.js.map +1 -0
- package/dist/api/bootstrap-endpoint.d.ts +1 -2
- package/dist/api/bootstrap-endpoint.js +42 -24
- package/dist/api/bootstrap-endpoint.js.map +1 -1
- package/dist/api/codex-doctor-endpoint.d.ts +22 -5
- package/dist/api/codex-doctor-endpoint.js +136 -17
- package/dist/api/codex-doctor-endpoint.js.map +1 -1
- package/dist/api/debug-report-endpoint.d.ts +27 -0
- package/dist/api/debug-report-endpoint.js +157 -0
- package/dist/api/debug-report-endpoint.js.map +1 -0
- package/dist/api/discovery-endpoint.d.ts +1 -0
- package/dist/api/discovery-endpoint.js +24 -0
- package/dist/api/discovery-endpoint.js.map +1 -1
- package/dist/api/gather-status.d.ts +33 -0
- package/dist/api/gather-status.js +211 -26
- package/dist/api/gather-status.js.map +1 -1
- package/dist/api/hermes-doctor-endpoint.d.ts +15 -7
- package/dist/api/hermes-doctor-endpoint.js +56 -19
- package/dist/api/hermes-doctor-endpoint.js.map +1 -1
- package/dist/api/launcher-status.d.ts +4 -2
- package/dist/api/launcher-status.js +11 -10
- package/dist/api/launcher-status.js.map +1 -1
- package/dist/api/launcher-tasks.d.ts +1 -1
- package/dist/api/launcher-tasks.js +12 -8
- package/dist/api/launcher-tasks.js.map +1 -1
- package/dist/api/operator-artifacts-endpoint.js +73 -6
- package/dist/api/operator-artifacts-endpoint.js.map +1 -1
- package/dist/api/portfolio-v0-build.d.ts +7 -1
- package/dist/api/portfolio-v0-build.js +6 -2
- package/dist/api/portfolio-v0-build.js.map +1 -1
- package/dist/api/prediction-v1-build.d.ts +6 -0
- package/dist/api/prediction-v1-build.js +3 -1
- package/dist/api/prediction-v1-build.js.map +1 -1
- package/dist/api/server.d.ts +17 -0
- package/dist/api/server.js +40 -1
- package/dist/api/server.js.map +1 -1
- package/dist/api/setup-endpoints.d.ts +0 -9
- package/dist/api/setup-endpoints.js +11 -153
- package/dist/api/setup-endpoints.js.map +1 -1
- package/dist/api/solvernets-endpoints.js +30 -63
- package/dist/api/solvernets-endpoints.js.map +1 -1
- package/dist/api/status-build.d.ts +115 -2
- package/dist/api/status-build.js +47 -11
- package/dist/api/status-build.js.map +1 -1
- package/dist/api/status-harness-rollup.d.ts +35 -0
- package/dist/api/status-harness-rollup.js +45 -0
- package/dist/api/status-harness-rollup.js.map +1 -0
- package/dist/api/task-runs-build.d.ts +8 -0
- package/dist/api/task-runs-build.js +5 -1
- package/dist/api/task-runs-build.js.map +1 -1
- package/dist/build-info.json +4 -4
- package/dist/build-meta.json +1 -1
- package/dist/captures/live-publisher.js +24 -4
- package/dist/captures/live-publisher.js.map +1 -1
- package/dist/captures/publish.d.ts +1 -1
- package/dist/chain-read-errors.d.ts +12 -0
- package/dist/chain-read-errors.js +26 -1
- package/dist/chain-read-errors.js.map +1 -1
- package/dist/cli/commands/codedigest-revert-check.d.ts +33 -0
- package/dist/cli/commands/codedigest-revert-check.js +249 -0
- package/dist/cli/commands/codedigest-revert-check.js.map +1 -0
- package/dist/cli/commands/eval.d.ts +76 -0
- package/dist/cli/commands/eval.js +391 -0
- package/dist/cli/commands/eval.js.map +1 -0
- package/dist/cli/commands/solver-nets.d.ts +1 -0
- package/dist/cli/commands/solver-nets.js +177 -22
- package/dist/cli/commands/solver-nets.js.map +1 -1
- package/dist/cli/commands/solver-plugins-block.d.ts +33 -0
- package/dist/cli/commands/solver-plugins-block.js +118 -0
- package/dist/cli/commands/solver-plugins-block.js.map +1 -0
- package/dist/cli/commands/solver-plugins-feedback.d.ts +72 -0
- package/dist/cli/commands/solver-plugins-feedback.js +262 -0
- package/dist/cli/commands/solver-plugins-feedback.js.map +1 -0
- package/dist/cli/commands/solver-plugins-read.d.ts +54 -0
- package/dist/cli/commands/solver-plugins-read.js +259 -0
- package/dist/cli/commands/solver-plugins-read.js.map +1 -0
- package/dist/cli/commands/solver-plugins.d.ts +35 -0
- package/dist/cli/commands/solver-plugins.js +399 -2
- package/dist/cli/commands/solver-plugins.js.map +1 -1
- package/dist/cli/commands/tasks.js +15 -2
- package/dist/cli/commands/tasks.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/task-native-readiness.d.ts +7 -0
- package/dist/cli/task-native-readiness.js +7 -5
- package/dist/cli/task-native-readiness.js.map +1 -1
- package/dist/config.d.ts +199 -232
- package/dist/config.js +268 -107
- package/dist/config.js.map +1 -1
- package/dist/daemon/ai-units-gate.d.ts +54 -0
- package/dist/daemon/ai-units-gate.js +82 -0
- package/dist/daemon/ai-units-gate.js.map +1 -0
- package/dist/daemon/creator.js +13 -0
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +10 -0
- package/dist/daemon/daemon.js +203 -30
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/eviction-loop.d.ts +7 -0
- package/dist/daemon/eviction-loop.js +16 -0
- package/dist/daemon/eviction-loop.js.map +1 -1
- package/dist/daemon/gate-logger.d.ts +9 -0
- package/dist/daemon/gate-logger.js +2 -0
- package/dist/daemon/gate-logger.js.map +1 -0
- package/dist/daemon/jinn-claim-loop.js +22 -4
- package/dist/daemon/jinn-claim-loop.js.map +1 -1
- package/dist/daemon/readiness-gate.d.ts +1 -4
- package/dist/daemon/readiness-gate.js.map +1 -1
- package/dist/daemon/spend-cap-gate.d.ts +40 -0
- package/dist/daemon/spend-cap-gate.js +46 -0
- package/dist/daemon/spend-cap-gate.js.map +1 -0
- package/dist/dashboard/assets/index-CldYENtT.js +359 -0
- package/dist/dashboard/assets/index-CzKxvMcU.css +32 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/discovery/http.js +411 -2
- package/dist/discovery/http.js.map +1 -1
- package/dist/discovery/onchain.js +123 -5
- package/dist/discovery/onchain.js.map +1 -1
- package/dist/discovery/types.d.ts +202 -0
- package/dist/discovery/types.js +40 -0
- package/dist/discovery/types.js.map +1 -1
- package/dist/discovery/with-fallback.js +34 -0
- package/dist/discovery/with-fallback.js.map +1 -1
- package/dist/earning/bootstrap.d.ts +25 -3
- package/dist/earning/bootstrap.js +69 -15
- package/dist/earning/bootstrap.js.map +1 -1
- package/dist/earning/safe-adapter.js +34 -11
- package/dist/earning/safe-adapter.js.map +1 -1
- package/dist/earning/types.d.ts +6 -6
- package/dist/earning/viem-clients.d.ts +11 -4
- package/dist/earning/viem-clients.js +14 -5
- package/dist/earning/viem-clients.js.map +1 -1
- package/dist/erc8004/identity.d.ts +19 -3
- package/dist/erc8004/identity.js +38 -11
- package/dist/erc8004/identity.js.map +1 -1
- package/dist/erc8004/index.d.ts +1 -1
- package/dist/erc8004/index.js.map +1 -1
- package/dist/eval/eval-harness-run.d.ts +63 -0
- package/dist/eval/eval-harness-run.js +123 -0
- package/dist/eval/eval-harness-run.js.map +1 -0
- package/dist/eval/orchestrator.d.ts +146 -0
- package/dist/eval/orchestrator.js +221 -0
- package/dist/eval/orchestrator.js.map +1 -0
- package/dist/eval/resolve-slate-tasks.d.ts +35 -0
- package/dist/eval/resolve-slate-tasks.js +56 -0
- package/dist/eval/resolve-slate-tasks.js.map +1 -0
- package/dist/eval/slope.d.ts +29 -0
- package/dist/eval/slope.js +46 -0
- package/dist/eval/slope.js.map +1 -0
- package/dist/eval/train-sequence.d.ts +35 -0
- package/dist/eval/train-sequence.js +59 -0
- package/dist/eval/train-sequence.js.map +1 -0
- package/dist/eval/wilson.d.ts +45 -0
- package/dist/eval/wilson.js +48 -0
- package/dist/eval/wilson.js.map +1 -0
- package/dist/events/types.d.ts +2 -2
- package/dist/harnesses/cost-estimates.d.ts +10 -31
- package/dist/harnesses/cost-estimates.js +11 -43
- package/dist/harnesses/cost-estimates.js.map +1 -1
- package/dist/harnesses/engine/canonical-json.js +5 -3
- package/dist/harnesses/engine/canonical-json.js.map +1 -1
- package/dist/harnesses/engine/engine.d.ts +37 -4
- package/dist/harnesses/engine/engine.js +138 -17
- package/dist/harnesses/engine/engine.js.map +1 -1
- package/dist/harnesses/engine/persistence.d.ts +21 -4
- package/dist/harnesses/engine/persistence.js +43 -6
- package/dist/harnesses/engine/persistence.js.map +1 -1
- package/dist/harnesses/engine/state.d.ts +9 -0
- package/dist/harnesses/engine/state.js +23 -10
- package/dist/harnesses/engine/state.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/bootstrap.js +4 -2
- package/dist/harnesses/impls/hermes-agent/bootstrap.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/config-builder.d.ts +1 -1
- package/dist/harnesses/impls/hermes-agent/config-builder.js +4 -2
- package/dist/harnesses/impls/hermes-agent/config-builder.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/harness.d.ts +14 -0
- package/dist/harnesses/impls/hermes-agent/harness.js +16 -2
- package/dist/harnesses/impls/hermes-agent/harness.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/prompt.d.ts +6 -6
- package/dist/harnesses/impls/hermes-agent/prompt.js +6 -6
- package/dist/harnesses/impls/learner/adapters/claude-code.d.ts +17 -0
- package/dist/harnesses/impls/learner/adapters/claude-code.js +113 -14
- package/dist/harnesses/impls/learner/adapters/claude-code.js.map +1 -1
- package/dist/harnesses/impls/learner/adapters/codex-code.d.ts +9 -0
- package/dist/harnesses/impls/learner/adapters/codex-code.js +30 -8
- package/dist/harnesses/impls/learner/adapters/codex-code.js.map +1 -1
- package/dist/harnesses/impls/learner/harness.d.ts +24 -0
- package/dist/harnesses/impls/learner/harness.js +33 -4
- package/dist/harnesses/impls/learner/harness.js.map +1 -1
- package/dist/harnesses/impls/learner/harvest.d.ts +3 -1
- package/dist/harnesses/impls/learner/harvest.js +30 -6
- package/dist/harnesses/impls/learner/harvest.js.map +1 -1
- package/dist/harnesses/impls/learner/restoration-patch.d.ts +2 -2
- package/dist/harnesses/impls/learner/restoration-patch.js +25 -6
- package/dist/harnesses/impls/learner/restoration-patch.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +21 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.d.ts +74 -5
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js +103 -32
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js.map +1 -1
- package/dist/harnesses/readiness-registry.d.ts +7 -0
- package/dist/harnesses/readiness-registry.js +9 -0
- package/dist/harnesses/readiness-registry.js.map +1 -1
- package/dist/learner/revert-decision.d.ts +59 -0
- package/dist/learner/revert-decision.js +53 -0
- package/dist/learner/revert-decision.js.map +1 -0
- package/dist/learner/revert-stats.d.ts +24 -0
- package/dist/learner/revert-stats.js +44 -0
- package/dist/learner/revert-stats.js.map +1 -0
- package/dist/main.js +178 -104
- package/dist/main.js.map +1 -1
- package/dist/mcp/get-codedigest-reward.d.ts +13 -0
- package/dist/mcp/get-codedigest-reward.js +23 -0
- package/dist/mcp/get-codedigest-reward.js.map +1 -0
- package/dist/mcp/server.js +23 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/observability/debug-report-assemble.d.ts +43 -0
- package/dist/observability/debug-report-assemble.js +80 -0
- package/dist/observability/debug-report-assemble.js.map +1 -0
- package/dist/observability/emit-event.d.ts +9 -2
- package/dist/observability/emit-event.js +36 -2
- package/dist/observability/emit-event.js.map +1 -1
- package/dist/observability/file-logger.d.ts +69 -0
- package/dist/observability/file-logger.js +177 -0
- package/dist/observability/file-logger.js.map +1 -0
- package/dist/observability/redact-secrets.d.ts +65 -0
- package/dist/observability/redact-secrets.js +300 -0
- package/dist/observability/redact-secrets.js.map +1 -0
- package/dist/observability/tar.d.ts +30 -0
- package/dist/observability/tar.js +102 -0
- package/dist/observability/tar.js.map +1 -0
- package/dist/plugins/learner/hooks/session-start +18 -1
- package/dist/plugins/learner/skills/learn/consolidator-prompt.md +18 -1
- package/dist/plugins/learner/skills/learn/promoter-prompt.md +72 -1
- package/dist/preflight/pidfile-liveness.d.ts +50 -0
- package/dist/preflight/pidfile-liveness.js +117 -0
- package/dist/preflight/pidfile-liveness.js.map +1 -0
- package/dist/preflight/rpc-network.d.ts +40 -0
- package/dist/preflight/rpc-network.js +67 -1
- package/dist/preflight/rpc-network.js.map +1 -1
- package/dist/rpc/transport.d.ts +109 -0
- package/dist/rpc/transport.js +220 -0
- package/dist/rpc/transport.js.map +1 -0
- package/dist/scripts/donation-consumption-acceptance.js +7 -28
- package/dist/scripts/donation-consumption-acceptance.js.map +1 -1
- package/dist/scripts/swe-rebench-v2-pytest-missing.json +16 -0
- package/dist/solver-nets/prediction-operator-ux.d.ts +1 -2
- package/dist/solver-nets/prediction-operator-ux.js +56 -53
- package/dist/solver-nets/prediction-operator-ux.js.map +1 -1
- package/dist/solver-nets/registry.d.ts +19 -1
- package/dist/solver-nets/registry.js +37 -24
- package/dist/solver-nets/registry.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-held-out-slate.d.ts +64 -0
- package/dist/solver-types/_swe-rebench-v2-held-out-slate.js +139 -0
- package/dist/solver-types/_swe-rebench-v2-held-out-slate.js.map +1 -0
- package/dist/solver-types/_swe-rebench-v2-pool.d.ts +9 -2
- package/dist/solver-types/_swe-rebench-v2-pool.js +15 -20
- package/dist/solver-types/_swe-rebench-v2-pool.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-state.d.ts +15 -0
- package/dist/solver-types/_swe-rebench-v2-state.js +19 -0
- package/dist/solver-types/_swe-rebench-v2-state.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-validated-pool.d.ts +116 -2
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js +296 -21
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js.map +1 -1
- package/dist/solver-types/slates/held-out-slate.swe-rebench-v2.v1.json +20 -0
- package/dist/solver-types/solver-type.d.ts +8 -0
- package/dist/solver-types/swe-rebench-v2-auto.d.ts +20 -11
- package/dist/solver-types/swe-rebench-v2-auto.js +64 -19
- package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -1
- package/dist/solver-types/swe-rebench-v2.d.ts +8 -2
- package/dist/solver-types/swe-rebench-v2.js +151 -12
- package/dist/solver-types/swe-rebench-v2.js.map +1 -1
- package/dist/solvernets/daemon-init.d.ts +1 -1
- package/dist/solvernets/daemon-init.js +19 -4
- package/dist/solvernets/daemon-init.js.map +1 -1
- package/dist/solvernets/launched-record-dispatcher.d.ts +4 -0
- package/dist/solvernets/launched-record-dispatcher.js +10 -4
- package/dist/solvernets/launched-record-dispatcher.js.map +1 -1
- package/dist/solvernets/registry-client-erc8004.js +11 -0
- package/dist/solvernets/registry-client-erc8004.js.map +1 -1
- package/dist/solvernets/store.d.ts +2 -2
- package/dist/solvernets/store.js +7 -2
- package/dist/solvernets/store.js.map +1 -1
- package/dist/spend/ai-units-config.d.ts +39 -0
- package/dist/spend/ai-units-config.js +28 -0
- package/dist/spend/ai-units-config.js.map +1 -0
- package/dist/spend/ai-units.d.ts +89 -0
- package/dist/spend/ai-units.js +156 -0
- package/dist/spend/ai-units.js.map +1 -0
- package/dist/spend/cost-surface-status.d.ts +12 -0
- package/dist/spend/cost-surface-status.js +24 -0
- package/dist/spend/cost-surface-status.js.map +1 -0
- package/dist/spend/credential.d.ts +39 -0
- package/dist/spend/credential.js +71 -0
- package/dist/spend/credential.js.map +1 -0
- package/dist/spend/daemon-config.d.ts +13 -0
- package/dist/spend/daemon-config.js +24 -0
- package/dist/spend/daemon-config.js.map +1 -0
- package/dist/spend/pricing.d.ts +16 -0
- package/dist/spend/pricing.js +26 -0
- package/dist/spend/pricing.js.map +1 -0
- package/dist/spend/record.d.ts +13 -0
- package/dist/spend/record.js +36 -0
- package/dist/spend/record.js.map +1 -0
- package/dist/spend/usage.d.ts +27 -0
- package/dist/spend/usage.js +113 -0
- package/dist/spend/usage.js.map +1 -0
- package/dist/store/store.d.ts +144 -0
- package/dist/store/store.js +396 -4
- package/dist/store/store.js.map +1 -1
- package/dist/trajectory/transcript-parsers/codex-session.d.ts +12 -6
- package/dist/trajectory/transcript-parsers/codex-session.js +114 -13
- package/dist/trajectory/transcript-parsers/codex-session.js.map +1 -1
- package/dist/trajectory/transcript-parsers/types.d.ts +8 -8
- package/dist/trajectory/transcript-session-dirs.d.ts +18 -0
- package/dist/trajectory/transcript-session-dirs.js +85 -0
- package/dist/trajectory/transcript-session-dirs.js.map +1 -0
- package/dist/trajectory/transcript-watcher.d.ts +20 -1
- package/dist/trajectory/transcript-watcher.js +108 -32
- package/dist/trajectory/transcript-watcher.js.map +1 -1
- package/dist/tx-retry.d.ts +25 -0
- package/dist/tx-retry.js +95 -7
- package/dist/tx-retry.js.map +1 -1
- package/dist/types/payloads/portfolio-v0.d.ts +3 -3
- package/dist/types/payloads/prediction-apy-v0.d.ts +3 -3
- package/dist/types/payloads/prediction-v0.d.ts +12 -12
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2-held-out-slate.d.ts +65 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2-held-out-slate.js +123 -0
- package/dist/vendor/@jinn-network/sdk/package.json +4 -0
- package/package.json +21 -12
- package/plugins/learner/hooks/session-start +18 -1
- package/plugins/learner/skills/learn/consolidator-prompt.md +18 -1
- package/plugins/learner/skills/learn/promoter-prompt.md +72 -1
- package/plugins/swe-rebench-v2-diffmin/README.md +10 -9
- package/plugins/swe-rebench-v2-diffmin/jinn.plugin.json +1 -1
- package/plugins/swe-rebench-v2-diffmin/skills/diffmin/SKILL.md +15 -10
- package/plugins/swe-rebench-v2-diffmin/skills/test-map/SKILL.md +10 -12
- package/plugins/swe-rebench-v2-runtime/.claude-plugin/plugin.json +1 -1
- package/plugins/swe-rebench-v2-runtime/.codex-plugin/plugin.json +3 -3
- package/plugins/swe-rebench-v2-runtime/README.md +6 -6
- package/plugins/swe-rebench-v2-runtime/jinn.plugin.json +2 -3
- package/plugins/swe-rebench-v2-runtime/skills/task/SKILL.md +81 -0
- package/dist/dashboard/assets/index-BUlE8F3Y.js +0 -330
- package/dist/dashboard/assets/index-blqc7eqq.css +0 -32
- package/plugins/swe-rebench-v2-runtime/skills/orient/SKILL.md +0 -29
- package/plugins/swe-rebench-v2-runtime/skills/plan/SKILL.md +0 -53
|
@@ -17,14 +17,15 @@
|
|
|
17
17
|
* Heuristic shape per the spec:
|
|
18
18
|
* per-1k-token rate × typical task length, by model id.
|
|
19
19
|
*
|
|
20
|
-
* Subscription
|
|
21
|
-
* `
|
|
22
|
-
*
|
|
23
|
-
* the confirmation gate, regardless of the model selected.
|
|
20
|
+
* Subscription billing paths (`usesPaidApiKey: false` from daemon
|
|
21
|
+
* `/v1/status` `costSurface`) show "Included in subscription, no per-task
|
|
22
|
+
* API cost" and **do not** trigger the confirmation gate.
|
|
24
23
|
*
|
|
25
24
|
* To add a new model: append an entry to `MODEL_COST_TABLE`. The id is the
|
|
26
|
-
* exact `model` string persisted to `joinedSolverNets[<cid>].model`.
|
|
27
|
-
*
|
|
25
|
+
* exact `model` string persisted to `joinedSolverNets[<cid>].model`. Paid
|
|
26
|
+
* vs subscription is resolved on the daemon via `resolveCredentialId` and
|
|
27
|
+
* exposed on `GET /v1/status` as `costSurface.harnesses[<canonical>]`.
|
|
28
|
+
* Keep the units
|
|
28
29
|
* consistent: token counts in tokens, rates in USD-per-1k-tokens.
|
|
29
30
|
*
|
|
30
31
|
* Units note: Anthropic + OpenAI publish prices per million tokens; we
|
|
@@ -69,21 +70,6 @@ export interface ModelCostEntry {
|
|
|
69
70
|
* `claudeModels.ts` is the source of truth for which ids appear here.
|
|
70
71
|
*/
|
|
71
72
|
export declare const MODEL_COST_TABLE: Readonly<Record<string, ModelCostEntry>>;
|
|
72
|
-
/**
|
|
73
|
-
* Harness-level billing classification.
|
|
74
|
-
*
|
|
75
|
-
* `subscriptionPath: true` means the harness shells out to a
|
|
76
|
-
* subscription-billed CLI (Claude Code, Codex) and the operator does NOT
|
|
77
|
-
* incur per-task API charges — the cost surface is suppressed entirely
|
|
78
|
-
* and the confirmation gate is never triggered.
|
|
79
|
-
*
|
|
80
|
-
* `subscriptionPath: false` means the harness routes to a paid API key
|
|
81
|
-
* (Hermes via OpenRouter / Anthropic API / Nous Portal). The cost surface
|
|
82
|
-
* is shown and the gate fires above the configured threshold.
|
|
83
|
-
*/
|
|
84
|
-
export declare const HARNESS_BILLING: Readonly<Record<string, {
|
|
85
|
-
subscriptionPath: boolean;
|
|
86
|
-
}>>;
|
|
87
73
|
/** Default per-task USD threshold above which the confirmation gate fires. */
|
|
88
74
|
export declare const DEFAULT_HIGH_COST_THRESHOLD_USD = 1;
|
|
89
75
|
export interface CostEstimate {
|
|
@@ -106,13 +92,6 @@ export interface CostEstimate {
|
|
|
106
92
|
* that as "unknown, don't surface a number" rather than rendering $0.
|
|
107
93
|
*/
|
|
108
94
|
export declare function estimateModelCost(modelId: string): CostEstimate | null;
|
|
109
|
-
/**
|
|
110
|
-
* `true` when the harness routes through a paid API key. Subscription
|
|
111
|
-
* harnesses (Claude Code, Codex) return `false`; unknown harnesses
|
|
112
|
-
* conservatively return `true` so a misnamed harness doesn't silently
|
|
113
|
-
* skip the cost surface.
|
|
114
|
-
*/
|
|
115
|
-
export declare function harnessUsesPaidApiKey(harness: string | undefined): boolean;
|
|
116
95
|
export interface CostSurfaceDecision {
|
|
117
96
|
/** Whether to show a numeric cost-per-task estimate at all. */
|
|
118
97
|
showEstimate: boolean;
|
|
@@ -133,11 +112,11 @@ export interface CostSurfaceDecision {
|
|
|
133
112
|
*
|
|
134
113
|
* Defaults:
|
|
135
114
|
* - threshold: $1 / task (see DEFAULT_HIGH_COST_THRESHOLD_USD).
|
|
136
|
-
* -
|
|
137
|
-
* - unknown model on a paid
|
|
115
|
+
* - `usesPaidApiKey: false` → suppress surface + skip gate.
|
|
116
|
+
* - unknown model on a paid path → show estimate slot (caller may
|
|
138
117
|
* render "estimate unavailable") but DO NOT trigger the gate.
|
|
139
118
|
*/
|
|
140
|
-
export declare function decideCostSurface(
|
|
119
|
+
export declare function decideCostSurface(usesPaidApiKey: boolean, modelId: string | undefined, thresholdUsd?: number): CostSurfaceDecision;
|
|
141
120
|
/**
|
|
142
121
|
* Format a USD amount for compact display in the dashboard. Picks the
|
|
143
122
|
* smallest fraction count that still distinguishes the value from $0.
|
|
@@ -17,14 +17,15 @@
|
|
|
17
17
|
* Heuristic shape per the spec:
|
|
18
18
|
* per-1k-token rate × typical task length, by model id.
|
|
19
19
|
*
|
|
20
|
-
* Subscription
|
|
21
|
-
* `
|
|
22
|
-
*
|
|
23
|
-
* the confirmation gate, regardless of the model selected.
|
|
20
|
+
* Subscription billing paths (`usesPaidApiKey: false` from daemon
|
|
21
|
+
* `/v1/status` `costSurface`) show "Included in subscription, no per-task
|
|
22
|
+
* API cost" and **do not** trigger the confirmation gate.
|
|
24
23
|
*
|
|
25
24
|
* To add a new model: append an entry to `MODEL_COST_TABLE`. The id is the
|
|
26
|
-
* exact `model` string persisted to `joinedSolverNets[<cid>].model`.
|
|
27
|
-
*
|
|
25
|
+
* exact `model` string persisted to `joinedSolverNets[<cid>].model`. Paid
|
|
26
|
+
* vs subscription is resolved on the daemon via `resolveCredentialId` and
|
|
27
|
+
* exposed on `GET /v1/status` as `costSurface.harnesses[<canonical>]`.
|
|
28
|
+
* Keep the units
|
|
28
29
|
* consistent: token counts in tokens, rates in USD-per-1k-tokens.
|
|
29
30
|
*
|
|
30
31
|
* Units note: Anthropic + OpenAI publish prices per million tokens; we
|
|
@@ -43,7 +44,6 @@
|
|
|
43
44
|
* These are heuristics. Provider-API reconciliation (actual usage) is
|
|
44
45
|
* deferred to the P1 follow-up tracked in #331.
|
|
45
46
|
*/
|
|
46
|
-
import { CLAUDE_CODE_HARNESS, CODEX_HARNESS, HERMES_AGENT_HARNESS, canonicalHarnessName, } from './names.js';
|
|
47
47
|
/**
|
|
48
48
|
* Per-model cost entries. Keyed by the exact `model` id persisted to
|
|
49
49
|
* `joinedSolverNets[<cid>].model`. The dashboard model dropdown in
|
|
@@ -187,23 +187,6 @@ export const MODEL_COST_TABLE = {
|
|
|
187
187
|
typicalOutputTokens: 20_000,
|
|
188
188
|
},
|
|
189
189
|
};
|
|
190
|
-
/**
|
|
191
|
-
* Harness-level billing classification.
|
|
192
|
-
*
|
|
193
|
-
* `subscriptionPath: true` means the harness shells out to a
|
|
194
|
-
* subscription-billed CLI (Claude Code, Codex) and the operator does NOT
|
|
195
|
-
* incur per-task API charges — the cost surface is suppressed entirely
|
|
196
|
-
* and the confirmation gate is never triggered.
|
|
197
|
-
*
|
|
198
|
-
* `subscriptionPath: false` means the harness routes to a paid API key
|
|
199
|
-
* (Hermes via OpenRouter / Anthropic API / Nous Portal). The cost surface
|
|
200
|
-
* is shown and the gate fires above the configured threshold.
|
|
201
|
-
*/
|
|
202
|
-
export const HARNESS_BILLING = {
|
|
203
|
-
[CLAUDE_CODE_HARNESS]: { subscriptionPath: true },
|
|
204
|
-
[CODEX_HARNESS]: { subscriptionPath: true },
|
|
205
|
-
[HERMES_AGENT_HARNESS]: { subscriptionPath: false },
|
|
206
|
-
};
|
|
207
190
|
/** Default per-task USD threshold above which the confirmation gate fires. */
|
|
208
191
|
export const DEFAULT_HIGH_COST_THRESHOLD_USD = 1;
|
|
209
192
|
/**
|
|
@@ -226,33 +209,18 @@ export function estimateModelCost(modelId) {
|
|
|
226
209
|
entry,
|
|
227
210
|
};
|
|
228
211
|
}
|
|
229
|
-
/**
|
|
230
|
-
* `true` when the harness routes through a paid API key. Subscription
|
|
231
|
-
* harnesses (Claude Code, Codex) return `false`; unknown harnesses
|
|
232
|
-
* conservatively return `true` so a misnamed harness doesn't silently
|
|
233
|
-
* skip the cost surface.
|
|
234
|
-
*/
|
|
235
|
-
export function harnessUsesPaidApiKey(harness) {
|
|
236
|
-
if (!harness)
|
|
237
|
-
return false;
|
|
238
|
-
const canonical = canonicalHarnessName(harness);
|
|
239
|
-
const billing = HARNESS_BILLING[canonical];
|
|
240
|
-
if (!billing)
|
|
241
|
-
return true;
|
|
242
|
-
return !billing.subscriptionPath;
|
|
243
|
-
}
|
|
244
212
|
/**
|
|
245
213
|
* Decide what the cost surface should render for a given harness + model
|
|
246
214
|
* combination, plus whether the confirmation gate fires.
|
|
247
215
|
*
|
|
248
216
|
* Defaults:
|
|
249
217
|
* - threshold: $1 / task (see DEFAULT_HIGH_COST_THRESHOLD_USD).
|
|
250
|
-
* -
|
|
251
|
-
* - unknown model on a paid
|
|
218
|
+
* - `usesPaidApiKey: false` → suppress surface + skip gate.
|
|
219
|
+
* - unknown model on a paid path → show estimate slot (caller may
|
|
252
220
|
* render "estimate unavailable") but DO NOT trigger the gate.
|
|
253
221
|
*/
|
|
254
|
-
export function decideCostSurface(
|
|
255
|
-
if (!
|
|
222
|
+
export function decideCostSurface(usesPaidApiKey, modelId, thresholdUsd = DEFAULT_HIGH_COST_THRESHOLD_USD) {
|
|
223
|
+
if (!usesPaidApiKey) {
|
|
256
224
|
return {
|
|
257
225
|
showEstimate: false,
|
|
258
226
|
estimate: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cost-estimates.js","sourceRoot":"","sources":["../../src/harnesses/cost-estimates.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
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,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,IAAI,MAAM,GAAG,EAAE;QAAE,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAChD,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -22,9 +22,11 @@
|
|
|
22
22
|
* Used for manifest signing: produce a deterministic byte string that two
|
|
23
23
|
* independent parties can reproduce from the same object graph.
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// canonicalize v3 is ESM-only (no CJS entry); the client is `"type": "module"`
|
|
26
|
+
// so a native ESM default import is the correct interop (replaces the v2-era
|
|
27
|
+
// createRequire shim). v3 is packaging-only vs v2 — its RFC 8785 output is
|
|
28
|
+
// byte-identical, so existing content hashes / manifest signatures are stable.
|
|
29
|
+
import canonicalize from 'canonicalize';
|
|
28
30
|
/**
|
|
29
31
|
* Recursively replace NaN / ±Infinity with null so that canonicalize does not
|
|
30
32
|
* throw — matching the JSON.stringify behaviour that the rest of the codebase
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonical-json.js","sourceRoot":"","sources":["../../../src/harnesses/engine/canonical-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,
|
|
1
|
+
{"version":3,"file":"canonical-json.js","sourceRoot":"","sources":["../../../src/harnesses/engine/canonical-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC3E,+EAA+E;AAC/E,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC;;;;;GAKG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC5D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,mEAAmE;QACnE,qEAAqE;QACrE,sEAAsE;QACtE,WAAW;QACX,MAAM,MAAM,GAAI,KAAoC,CAAC,MAAM,CAAC;QAC5D,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;YACjC,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7C,CAAC;QACD,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;QACxE,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAEvC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,wEAAwE;QACxE,uEAAuE;QACvE,kCAAkC;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -329,9 +329,15 @@ export declare class TaskEngine {
|
|
|
329
329
|
* Performance contract (issue #398): this runs once per task announcement,
|
|
330
330
|
* on the engine-watcher hot path, for every observed task. It MUST NOT
|
|
331
331
|
* perform per-task blocking I/O. In particular it does not probe
|
|
332
|
-
* `impl.isReady()` —
|
|
333
|
-
*
|
|
334
|
-
* spawns and starve the daemon event loop.
|
|
332
|
+
* `impl.isReady()` — historically the Hermes harness ran child processes
|
|
333
|
+
* inside its readiness probe, so a backlog would pay per-task blocking
|
|
334
|
+
* spawns and starve the daemon event loop. (#778 converted the matching
|
|
335
|
+
* post-execution `git diff` wedge in harvest.ts to async + 60s timeout;
|
|
336
|
+
* the #778 follow-up converted the readiness-probe spawns themselves —
|
|
337
|
+
* Hermes `doctor` / `auth list` and the codex-doctor `--version` probe —
|
|
338
|
+
* to async, so the registry's background refresh loop no longer blocks the
|
|
339
|
+
* main thread either. The readiness path remains O(1) here via the cache
|
|
340
|
+
* below.)
|
|
335
341
|
*
|
|
336
342
|
* Harness readiness for the claim gate is instead served O(1) from the
|
|
337
343
|
* daemon's cached `HarnessReadinessRegistry` snapshot: the engine-watcher
|
|
@@ -561,9 +567,36 @@ export declare class TaskEngine {
|
|
|
561
567
|
* when a previous run already produced the data.
|
|
562
568
|
*/
|
|
563
569
|
private dataDrivenAdvance;
|
|
570
|
+
/**
|
|
571
|
+
* Classify a transition error and mark the task terminal accordingly.
|
|
572
|
+
*
|
|
573
|
+
* - `SafeInnerRevertError` with a non-recoverable inner name (the same
|
|
574
|
+
* set the daemon's pre-claim catch in `emitTickErrorOrRaceLost` uses):
|
|
575
|
+
* the on-chain slot is already pruned (TCMaxVerdictsReached,
|
|
576
|
+
* TCAttemptAlreadyFinalized, …). We mark the row RACE_LOST and emit a
|
|
577
|
+
* `kind=race_lost` activity event so operators can audit prunes
|
|
578
|
+
* without inflating the FAILED counter (#896).
|
|
579
|
+
* - A transport-transient error (e.g. `AllRpcsFailedError` — every provider
|
|
580
|
+
* in the L2 fallback chain failed at once) on a task whose delivery window
|
|
581
|
+
* is still open: leave the row in its current in-flight state so the next
|
|
582
|
+
* tick re-drives it once the RPCs recover, and emit a `tick_error` (warn)
|
|
583
|
+
* event instead of inflating the FAILED counter. Without this the daemon
|
|
584
|
+
* stamped the row FAILED, dropping it from `getInFlight()` permanently, so
|
|
585
|
+
* L2 work went silent until a manual restart (#912). Past-window transient
|
|
586
|
+
* errors still terminalize to avoid churning on work that can no longer
|
|
587
|
+
* settle.
|
|
588
|
+
* - Everything else: existing markFailed behaviour. When invoked from
|
|
589
|
+
* recovery, `contextLabel === 'recovery'` so the failure_reason
|
|
590
|
+
* carries the `recovery:` prefix the original code path used.
|
|
591
|
+
*
|
|
592
|
+
* Returns the classification so callers can log appropriately.
|
|
593
|
+
*/
|
|
594
|
+
private _classifyAndMarkTerminal;
|
|
564
595
|
/**
|
|
565
596
|
* Wraps a transition method call with error handling: if the transition
|
|
566
|
-
* throws, the task is marked FAILED
|
|
597
|
+
* throws, the task is marked terminal (FAILED or RACE_LOST per
|
|
598
|
+
* `_classifyAndMarkTerminal`) and the error is rethrown so the caller can
|
|
599
|
+
* surface it.
|
|
567
600
|
*/
|
|
568
601
|
private _runTransition;
|
|
569
602
|
/**
|
|
@@ -16,8 +16,11 @@ import { provisionWorkingDir, provisionImplStateDir, walkArtifacts, uploadArtifa
|
|
|
16
16
|
import { DONATION_ARTIFACT_ENCODING } from './artifact-scrub.js';
|
|
17
17
|
import { assembleAndSignEnvelope, } from './envelope-assembly.js';
|
|
18
18
|
import { deliverAndClaim, } from './delivery.js';
|
|
19
|
+
import { SafeInnerRevertError, isNonRecoverableInnerRevert, formatDecodedRevert, } from '../../adapters/mech/safe-revert.js';
|
|
20
|
+
import { emitEvent } from '../../observability/emit-event.js';
|
|
21
|
+
import { isRecoverableTransactionError } from '../../tx-retry.js';
|
|
19
22
|
import { SkippableError } from '../types.js';
|
|
20
|
-
import { submitEvaluatorFeedback, codeDigestSha256ToBytes32, modeStringToFlag, } from '../../erc8004/index.js';
|
|
23
|
+
import { submitEvaluatorFeedback, codeDigestSha256ToBytes32, encodeExecutionPayload, encodeExecutionPayloadV2, modeStringToFlag, } from '../../erc8004/index.js';
|
|
21
24
|
import { TrajectoryCollector, emitTrajectory } from '../../trajectory/index.js';
|
|
22
25
|
import { uploadToIpfs } from '../../adapters/mech/ipfs.js';
|
|
23
26
|
import { VerdictCode } from '../../adapters/mech/verdict-code.js';
|
|
@@ -25,6 +28,7 @@ import { buildInfo } from '../../build-info.js';
|
|
|
25
28
|
import { getSolverNetContract } from '../../vendor/@jinn-network/sdk/dist/solvernets/index.js';
|
|
26
29
|
import { runHarnessWithFreezeFence, } from '../../daemon/freeze-fence.js';
|
|
27
30
|
import { harnessStateDirName } from '../names.js';
|
|
31
|
+
import { recordTaskCost } from '../../spend/record.js';
|
|
28
32
|
// ── Sentinel error ────────────────────────────────────────────────────────────
|
|
29
33
|
export class NotImplementedError extends Error {
|
|
30
34
|
transitionName;
|
|
@@ -150,9 +154,15 @@ export class TaskEngine {
|
|
|
150
154
|
* Performance contract (issue #398): this runs once per task announcement,
|
|
151
155
|
* on the engine-watcher hot path, for every observed task. It MUST NOT
|
|
152
156
|
* perform per-task blocking I/O. In particular it does not probe
|
|
153
|
-
* `impl.isReady()` —
|
|
154
|
-
*
|
|
155
|
-
* spawns and starve the daemon event loop.
|
|
157
|
+
* `impl.isReady()` — historically the Hermes harness ran child processes
|
|
158
|
+
* inside its readiness probe, so a backlog would pay per-task blocking
|
|
159
|
+
* spawns and starve the daemon event loop. (#778 converted the matching
|
|
160
|
+
* post-execution `git diff` wedge in harvest.ts to async + 60s timeout;
|
|
161
|
+
* the #778 follow-up converted the readiness-probe spawns themselves —
|
|
162
|
+
* Hermes `doctor` / `auth list` and the codex-doctor `--version` probe —
|
|
163
|
+
* to async, so the registry's background refresh loop no longer blocks the
|
|
164
|
+
* main thread either. The readiness path remains O(1) here via the cache
|
|
165
|
+
* below.)
|
|
156
166
|
*
|
|
157
167
|
* Harness readiness for the claim gate is instead served O(1) from the
|
|
158
168
|
* daemon's cached `HarnessReadinessRegistry` snapshot: the engine-watcher
|
|
@@ -388,6 +398,7 @@ export class TaskEngine {
|
|
|
388
398
|
break;
|
|
389
399
|
case TaskRunState.COMPLETE:
|
|
390
400
|
case TaskRunState.FAILED:
|
|
401
|
+
case TaskRunState.RACE_LOST:
|
|
391
402
|
// Terminal — nothing to do.
|
|
392
403
|
break;
|
|
393
404
|
}
|
|
@@ -887,6 +898,18 @@ export class TaskEngine {
|
|
|
887
898
|
clearTimeout(endTimer);
|
|
888
899
|
}
|
|
889
900
|
console.log(`[harness-engine] ${task.requestId} RUNNING → POST_SNAPSHOT via impl=${impl.name}`);
|
|
901
|
+
// Record the run's cost once it has cleanly reached POST_SNAPSHOT — i.e. the
|
|
902
|
+
// harness completed. Captures cost regardless of whether on-chain delivery
|
|
903
|
+
// later succeeds. Pre-completion early-exits (SkippableError, freeze-fence
|
|
904
|
+
// violation) intentionally do not record: the spend cap is an approximate
|
|
905
|
+
// graceful-pause control (design spec §2), not a precise ledger.
|
|
906
|
+
recordTaskCost(this.store, {
|
|
907
|
+
requestId: task.requestId,
|
|
908
|
+
harness: impl.name,
|
|
909
|
+
model: solverNet?.model,
|
|
910
|
+
workingDir,
|
|
911
|
+
solverType: task.solverType ?? null,
|
|
912
|
+
});
|
|
890
913
|
}
|
|
891
914
|
async takePostSnapshot(_intent) {
|
|
892
915
|
throw new NotImplementedError('takePostSnapshot');
|
|
@@ -1312,6 +1335,8 @@ export class TaskEngine {
|
|
|
1312
1335
|
!!harnessImplName;
|
|
1313
1336
|
try {
|
|
1314
1337
|
let pubTxHash;
|
|
1338
|
+
let pubBlockNumber;
|
|
1339
|
+
let payloadHex;
|
|
1315
1340
|
if (canEmitV2) {
|
|
1316
1341
|
const v2Payload = {
|
|
1317
1342
|
version: 2,
|
|
@@ -1323,11 +1348,14 @@ export class TaskEngine {
|
|
|
1323
1348
|
implName: harnessImplName,
|
|
1324
1349
|
modeFlag: modeStringToFlag(task.executorMode),
|
|
1325
1350
|
};
|
|
1326
|
-
|
|
1351
|
+
payloadHex = encodeExecutionPayloadV2(v2Payload);
|
|
1352
|
+
const result = await this.identityPublisher.publishContentV2({
|
|
1327
1353
|
kind: metadataKind,
|
|
1328
1354
|
cid: manifestCid,
|
|
1329
1355
|
payload: v2Payload,
|
|
1330
1356
|
});
|
|
1357
|
+
pubTxHash = result.txHash;
|
|
1358
|
+
pubBlockNumber = result.blockNumber;
|
|
1331
1359
|
console.log(`[harness-engine] ${requestId}: setMetadata ${metadataKind}:${manifestCid} tx=${pubTxHash} (payload v2 mode=${task.executorMode} impl=${harnessImplName})`);
|
|
1332
1360
|
}
|
|
1333
1361
|
else {
|
|
@@ -1338,13 +1366,34 @@ export class TaskEngine {
|
|
|
1338
1366
|
attestationQuoteCid: '0x',
|
|
1339
1367
|
sourceMeasurement: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1340
1368
|
};
|
|
1341
|
-
|
|
1369
|
+
payloadHex = encodeExecutionPayload(v1Payload);
|
|
1370
|
+
const result = await this.identityPublisher.publishContent({
|
|
1342
1371
|
kind: metadataKind,
|
|
1343
1372
|
cid: manifestCid,
|
|
1344
1373
|
payload: v1Payload,
|
|
1345
1374
|
});
|
|
1375
|
+
pubTxHash = result.txHash;
|
|
1376
|
+
pubBlockNumber = result.blockNumber;
|
|
1346
1377
|
console.log(`[harness-engine] ${requestId}: setMetadata ${metadataKind}:${manifestCid} tx=${pubTxHash} (payload v1)`);
|
|
1347
1378
|
}
|
|
1379
|
+
try {
|
|
1380
|
+
this.store.saveErc8004Anchor({
|
|
1381
|
+
envelopeId: manifestHashHex,
|
|
1382
|
+
envelopeCid: manifestCid,
|
|
1383
|
+
contentKind: metadataKind,
|
|
1384
|
+
metadataKey: `${metadataKind}:${manifestCid}`,
|
|
1385
|
+
agentId: this.identityPublisher.agent.toString(),
|
|
1386
|
+
chainId: this.identityPublisher.chainId,
|
|
1387
|
+
identityRegistryAddress: this.identityPublisher.registry,
|
|
1388
|
+
txHash: pubTxHash,
|
|
1389
|
+
blockNumber: pubBlockNumber,
|
|
1390
|
+
payloadHex,
|
|
1391
|
+
anchoredAt: Math.floor(Date.now() / 1000),
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
catch (anchorErr) {
|
|
1395
|
+
console.warn(`[harness-engine] ${requestId}: failed to record erc8004 anchor (non-fatal): ${anchorErr instanceof Error ? anchorErr.message : anchorErr}`);
|
|
1396
|
+
}
|
|
1348
1397
|
}
|
|
1349
1398
|
catch (err) {
|
|
1350
1399
|
console.warn(`[harness-engine] ${requestId}: setMetadata ${metadataKind} publish failed (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
@@ -1573,9 +1622,73 @@ export class TaskEngine {
|
|
|
1573
1622
|
return null;
|
|
1574
1623
|
}
|
|
1575
1624
|
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Classify a transition error and mark the task terminal accordingly.
|
|
1627
|
+
*
|
|
1628
|
+
* - `SafeInnerRevertError` with a non-recoverable inner name (the same
|
|
1629
|
+
* set the daemon's pre-claim catch in `emitTickErrorOrRaceLost` uses):
|
|
1630
|
+
* the on-chain slot is already pruned (TCMaxVerdictsReached,
|
|
1631
|
+
* TCAttemptAlreadyFinalized, …). We mark the row RACE_LOST and emit a
|
|
1632
|
+
* `kind=race_lost` activity event so operators can audit prunes
|
|
1633
|
+
* without inflating the FAILED counter (#896).
|
|
1634
|
+
* - A transport-transient error (e.g. `AllRpcsFailedError` — every provider
|
|
1635
|
+
* in the L2 fallback chain failed at once) on a task whose delivery window
|
|
1636
|
+
* is still open: leave the row in its current in-flight state so the next
|
|
1637
|
+
* tick re-drives it once the RPCs recover, and emit a `tick_error` (warn)
|
|
1638
|
+
* event instead of inflating the FAILED counter. Without this the daemon
|
|
1639
|
+
* stamped the row FAILED, dropping it from `getInFlight()` permanently, so
|
|
1640
|
+
* L2 work went silent until a manual restart (#912). Past-window transient
|
|
1641
|
+
* errors still terminalize to avoid churning on work that can no longer
|
|
1642
|
+
* settle.
|
|
1643
|
+
* - Everything else: existing markFailed behaviour. When invoked from
|
|
1644
|
+
* recovery, `contextLabel === 'recovery'` so the failure_reason
|
|
1645
|
+
* carries the `recovery:` prefix the original code path used.
|
|
1646
|
+
*
|
|
1647
|
+
* Returns the classification so callers can log appropriately.
|
|
1648
|
+
*/
|
|
1649
|
+
_classifyAndMarkTerminal(task, err, contextLabel) {
|
|
1650
|
+
if (err instanceof SafeInnerRevertError &&
|
|
1651
|
+
isNonRecoverableInnerRevert(err.decodedName)) {
|
|
1652
|
+
// decodedName is non-null by virtue of isNonRecoverableInnerRevert.
|
|
1653
|
+
const detail = formatDecodedRevert(err.decodedName, err.decodedArgs);
|
|
1654
|
+
this.persistence.markRaceLost(task.requestId, detail);
|
|
1655
|
+
emitEvent(this.store, {
|
|
1656
|
+
kind: 'race_lost',
|
|
1657
|
+
requestId: task.requestId,
|
|
1658
|
+
solverType: task.solverType ?? undefined,
|
|
1659
|
+
outcome: 'ok',
|
|
1660
|
+
detail,
|
|
1661
|
+
}, 'harness-engine');
|
|
1662
|
+
return 'race_lost';
|
|
1663
|
+
}
|
|
1664
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1665
|
+
// A transport-transient failure (all RPC providers in the fallback chain
|
|
1666
|
+
// blipped at once, 429s, timeouts, …) is not the task's fault and is not
|
|
1667
|
+
// permanent. Leave the row in its in-flight state — do NOT call
|
|
1668
|
+
// markFailed, which would drop it from getInFlight() forever (#912) — so
|
|
1669
|
+
// the engine-tick loop re-drives it once the RPCs recover. The tick loop
|
|
1670
|
+
// IS the retry; there is no per-task attempt counter. Skip this only once
|
|
1671
|
+
// the delivery window has closed, so we never churn on work that can no
|
|
1672
|
+
// longer settle on-chain.
|
|
1673
|
+
if (task.windowEndTs > Date.now() && isRecoverableTransactionError(err)) {
|
|
1674
|
+
emitEvent(this.store, {
|
|
1675
|
+
kind: 'tick_error',
|
|
1676
|
+
requestId: task.requestId,
|
|
1677
|
+
solverType: task.solverType ?? undefined,
|
|
1678
|
+
outcome: 'warn',
|
|
1679
|
+
detail: `transient RPC failure in ${contextLabel}; left ${task.state} for retry: ${reason}`,
|
|
1680
|
+
}, 'harness-engine');
|
|
1681
|
+
return 'transient';
|
|
1682
|
+
}
|
|
1683
|
+
const stamped = contextLabel === 'recovery' ? `recovery: ${reason}` : reason;
|
|
1684
|
+
this.persistence.markFailed(task.requestId, stamped);
|
|
1685
|
+
return 'failed';
|
|
1686
|
+
}
|
|
1576
1687
|
/**
|
|
1577
1688
|
* Wraps a transition method call with error handling: if the transition
|
|
1578
|
-
* throws, the task is marked FAILED
|
|
1689
|
+
* throws, the task is marked terminal (FAILED or RACE_LOST per
|
|
1690
|
+
* `_classifyAndMarkTerminal`) and the error is rethrown so the caller can
|
|
1691
|
+
* surface it.
|
|
1579
1692
|
*/
|
|
1580
1693
|
async _runTransition(task, fn) {
|
|
1581
1694
|
// Each transition method (claim, takePreSnapshot, runImpl, pack, deliver)
|
|
@@ -1583,14 +1696,12 @@ export class TaskEngine {
|
|
|
1583
1696
|
// deliveryTx, impl name). We deliberately don't emit a generic
|
|
1584
1697
|
// `oldState → newState` line here: doing so produced duplicate
|
|
1585
1698
|
// transition lines in the operator log (jinn-mono-kzan). On failure,
|
|
1586
|
-
// the catch below
|
|
1587
|
-
// surface the error.
|
|
1699
|
+
// the catch below routes through the race-loss classifier and rethrows.
|
|
1588
1700
|
try {
|
|
1589
1701
|
await fn();
|
|
1590
1702
|
}
|
|
1591
1703
|
catch (err) {
|
|
1592
|
-
|
|
1593
|
-
this.persistence.markFailed(task.requestId, reason);
|
|
1704
|
+
this._classifyAndMarkTerminal(task, err, 'transition');
|
|
1594
1705
|
throw err;
|
|
1595
1706
|
}
|
|
1596
1707
|
}
|
|
@@ -1603,15 +1714,25 @@ export class TaskEngine {
|
|
|
1603
1714
|
await this._recoverDispatch(task);
|
|
1604
1715
|
}
|
|
1605
1716
|
catch (err) {
|
|
1606
|
-
// If recovery itself throws (e.g. NotImplementedError stub),
|
|
1607
|
-
//
|
|
1608
|
-
|
|
1609
|
-
// Only
|
|
1717
|
+
// If recovery itself throws (e.g. NotImplementedError stub), classify
|
|
1718
|
+
// the error and mark the row terminal. NotImplementedError is expected
|
|
1719
|
+
// during development; don't swallow it in prod.
|
|
1720
|
+
// Only act if the task is still in the same non-terminal state
|
|
1610
1721
|
// (another concurrent recovery pass might have already advanced it).
|
|
1611
1722
|
const current = this.persistence.getByRequestId(task.requestId);
|
|
1612
1723
|
if (current && current.state === task.state) {
|
|
1613
|
-
this.
|
|
1614
|
-
|
|
1724
|
+
const classification = this._classifyAndMarkTerminal(task, err, 'recovery');
|
|
1725
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1726
|
+
// 'transient' leaves the row in-flight (not terminal); the next tick
|
|
1727
|
+
// re-drives it once the RPCs recover (#912). Log it at warn so the
|
|
1728
|
+
// stall is visible without firing the error-level alerting that a
|
|
1729
|
+
// genuine failure does.
|
|
1730
|
+
const { log, verb } = {
|
|
1731
|
+
race_lost: { log: console.log, verb: 'pruned' },
|
|
1732
|
+
transient: { log: console.warn, verb: 'deferred (transient RPC)' },
|
|
1733
|
+
failed: { log: console.error, verb: 'failed' },
|
|
1734
|
+
}[classification];
|
|
1735
|
+
log(`[harness-engine] resume ${verb} for ${task.requestId}: ${reason}`);
|
|
1615
1736
|
}
|
|
1616
1737
|
throw err;
|
|
1617
1738
|
}
|