@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
package/dist/store/store.js
CHANGED
|
@@ -228,6 +228,23 @@ CREATE TABLE IF NOT EXISTS envelope_projection_metadata (
|
|
|
228
228
|
CREATE INDEX IF NOT EXISTS idx_envelope_projection_metadata_key_value
|
|
229
229
|
ON envelope_projection_metadata (key, value_text);
|
|
230
230
|
|
|
231
|
+
CREATE TABLE IF NOT EXISTS erc8004_anchors (
|
|
232
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
233
|
+
envelope_id TEXT NOT NULL,
|
|
234
|
+
envelope_cid TEXT NOT NULL,
|
|
235
|
+
content_kind TEXT NOT NULL,
|
|
236
|
+
metadata_key TEXT NOT NULL,
|
|
237
|
+
agent_id TEXT NOT NULL,
|
|
238
|
+
chain_id INTEGER NOT NULL,
|
|
239
|
+
identity_registry_address TEXT NOT NULL,
|
|
240
|
+
tx_hash TEXT NOT NULL,
|
|
241
|
+
block_number INTEGER,
|
|
242
|
+
payload_hex TEXT NOT NULL,
|
|
243
|
+
anchored_at INTEGER NOT NULL
|
|
244
|
+
);
|
|
245
|
+
CREATE INDEX IF NOT EXISTS idx_erc8004_anchors_envelope_cid ON erc8004_anchors(envelope_cid);
|
|
246
|
+
CREATE INDEX IF NOT EXISTS idx_erc8004_anchors_envelope_id ON erc8004_anchors(envelope_id);
|
|
247
|
+
|
|
231
248
|
CREATE TABLE IF NOT EXISTS task_post_locks (
|
|
232
249
|
creator_safe_address TEXT NOT NULL,
|
|
233
250
|
source_key TEXT NOT NULL,
|
|
@@ -271,6 +288,25 @@ CREATE TABLE IF NOT EXISTS capture_spans (
|
|
|
271
288
|
);
|
|
272
289
|
CREATE INDEX IF NOT EXISTS capture_spans_session ON capture_spans (session_id);
|
|
273
290
|
|
|
291
|
+
-- Held-out checkpoint eval results (issue #818). One row per
|
|
292
|
+
-- (checkpoint, slate version, instance). Scores are only comparable WITHIN a
|
|
293
|
+
-- slate version; slate_hash is stored so a version-bump / hash-drift is
|
|
294
|
+
-- detectable. passed is nullable: an unscorable row (Docker down, disk
|
|
295
|
+
-- floor) carries passed = NULL and is EXCLUDED from the denominator -- never
|
|
296
|
+
-- coerced to a fail.
|
|
297
|
+
CREATE TABLE IF NOT EXISTS eval_results (
|
|
298
|
+
checkpoint_cid TEXT NOT NULL,
|
|
299
|
+
slate_hash TEXT NOT NULL,
|
|
300
|
+
slate_version TEXT NOT NULL,
|
|
301
|
+
instance_id TEXT NOT NULL,
|
|
302
|
+
passed INTEGER,
|
|
303
|
+
unscorable INTEGER NOT NULL DEFAULT 0,
|
|
304
|
+
code_digest TEXT NOT NULL,
|
|
305
|
+
run_at_ms INTEGER NOT NULL,
|
|
306
|
+
test_log_excerpt TEXT,
|
|
307
|
+
PRIMARY KEY (checkpoint_cid, slate_version, instance_id)
|
|
308
|
+
);
|
|
309
|
+
|
|
274
310
|
`;
|
|
275
311
|
export class Store {
|
|
276
312
|
/** Exposed for engine persistence layer — treat as package-internal. */
|
|
@@ -299,6 +335,7 @@ export class Store {
|
|
|
299
335
|
this.ensureNetworkArtifactsPeerCatalogId();
|
|
300
336
|
this.ensureTaskPostsTaskCoordinatorColumns();
|
|
301
337
|
this.ensureEnvelopeProjectionColumns();
|
|
338
|
+
this.ensureActivityEventCostColumns();
|
|
302
339
|
this.backfillActivityEvents();
|
|
303
340
|
this.recordLegacyRestorationIntentsIgnored();
|
|
304
341
|
}
|
|
@@ -363,6 +400,30 @@ export class Store {
|
|
|
363
400
|
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_envelope_projections_solution_ref ON envelope_projections (solution_envelope_ref)`);
|
|
364
401
|
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_envelope_projections_generated ON envelope_projections (generated_at DESC)`);
|
|
365
402
|
}
|
|
403
|
+
/** Older local DBs predate the per-credential spend-ledger columns on activity_events. */
|
|
404
|
+
ensureActivityEventCostColumns() {
|
|
405
|
+
const activityCols = new Set(this.db.prepare(`PRAGMA table_info(activity_events)`).all()
|
|
406
|
+
.map(c => c.name));
|
|
407
|
+
const addActivityColumn = (name, ddl) => {
|
|
408
|
+
if (!activityCols.has(name))
|
|
409
|
+
this.db.exec(`ALTER TABLE activity_events ADD COLUMN ${ddl}`);
|
|
410
|
+
};
|
|
411
|
+
addActivityColumn('credential_id', 'credential_id TEXT');
|
|
412
|
+
addActivityColumn('cost_usd_micros', 'cost_usd_micros INTEGER');
|
|
413
|
+
addActivityColumn('model', 'model TEXT');
|
|
414
|
+
// Issue #815 — AI-units ceiling. ai_units is the gate-input projection
|
|
415
|
+
// captured at claim time; claim_status tracks the per-request lifecycle
|
|
416
|
+
// (claimed / claim_failed / delivered); the cost pair splits the
|
|
417
|
+
// estimated-at-claim-time vs actual-at-completion telemetry.
|
|
418
|
+
addActivityColumn('ai_units', 'ai_units REAL');
|
|
419
|
+
addActivityColumn('claim_status', 'claim_status TEXT');
|
|
420
|
+
addActivityColumn('estimated_cost_usd_micros', 'estimated_cost_usd_micros INTEGER');
|
|
421
|
+
addActivityColumn('actual_cost_usd_micros', 'actual_cost_usd_micros INTEGER');
|
|
422
|
+
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_activity_events_credential ON activity_events (credential_id, ts)`);
|
|
423
|
+
// Per-request lookup for the completion-time update path that fills
|
|
424
|
+
// actualCostUsdMicros / sets claim_status='delivered'.
|
|
425
|
+
this.db.exec(`CREATE INDEX IF NOT EXISTS idx_activity_events_req_claim ON activity_events (request_id, claim_status)`);
|
|
426
|
+
}
|
|
366
427
|
/**
|
|
367
428
|
* Task-native startup ignores the retired request-first `restoration_intents`
|
|
368
429
|
* table. Keep a one-time local marker when old in-flight rows are present so
|
|
@@ -417,6 +478,16 @@ export class Store {
|
|
|
417
478
|
const ts = new Date().toISOString();
|
|
418
479
|
this.recordActivityEvent({ ts, kind: role, requestId });
|
|
419
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* Membership-only variant of `recordOwnActivity`: writes the
|
|
483
|
+
* `own_activity` row but does NOT emit a generic `activity_events`
|
|
484
|
+
* row. Used by paths that emit their own enriched activity event
|
|
485
|
+
* (e.g. issue #815's claim path attaches credentialId / aiUnits /
|
|
486
|
+
* estimatedCostUsdMicros / claimStatus to the row).
|
|
487
|
+
*/
|
|
488
|
+
markOwnActivity(requestId, role) {
|
|
489
|
+
this.db.prepare(`INSERT OR REPLACE INTO own_activity (request_id, role) VALUES (?, ?)`).run(requestId, role);
|
|
490
|
+
}
|
|
420
491
|
isOwnActivity(requestId) {
|
|
421
492
|
const row = this.db.prepare('SELECT 1 FROM own_activity WHERE request_id = ?').get(requestId);
|
|
422
493
|
return row !== undefined;
|
|
@@ -746,8 +817,14 @@ export class Store {
|
|
|
746
817
|
return legacyRows.map(r => ({ requestId: r.request_id, role: r.role }));
|
|
747
818
|
}
|
|
748
819
|
recordActivityEvent(event) {
|
|
749
|
-
this.db.prepare(`INSERT INTO activity_events
|
|
750
|
-
|
|
820
|
+
this.db.prepare(`INSERT INTO activity_events
|
|
821
|
+
(ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
|
|
822
|
+
credential_id, cost_usd_micros, model,
|
|
823
|
+
ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros)
|
|
824
|
+
VALUES
|
|
825
|
+
(@ts, @kind, @requestId, @serviceIndex, @txHash, @solverType, @outcome, @detail,
|
|
826
|
+
@credentialId, @costUsdMicros, @model,
|
|
827
|
+
@aiUnits, @claimStatus, @estimatedCostUsdMicros, @actualCostUsdMicros)`).run({
|
|
751
828
|
ts: event.ts ?? null,
|
|
752
829
|
kind: event.kind,
|
|
753
830
|
requestId: event.requestId ?? null,
|
|
@@ -756,6 +833,13 @@ export class Store {
|
|
|
756
833
|
solverType: event.solverType ?? null,
|
|
757
834
|
outcome: event.outcome ?? null,
|
|
758
835
|
detail: event.detail ?? null,
|
|
836
|
+
credentialId: event.credentialId ?? null,
|
|
837
|
+
costUsdMicros: event.costUsdMicros ?? null,
|
|
838
|
+
model: event.model ?? null,
|
|
839
|
+
aiUnits: event.aiUnits ?? null,
|
|
840
|
+
claimStatus: event.claimStatus ?? null,
|
|
841
|
+
estimatedCostUsdMicros: event.estimatedCostUsdMicros ?? null,
|
|
842
|
+
actualCostUsdMicros: event.actualCostUsdMicros ?? null,
|
|
759
843
|
});
|
|
760
844
|
}
|
|
761
845
|
getRecentActivityEvents(limit, opts = {}) {
|
|
@@ -771,7 +855,9 @@ export class Store {
|
|
|
771
855
|
params['cursor'] = opts.cursor;
|
|
772
856
|
}
|
|
773
857
|
const where = clauses.length > 0 ? `WHERE ${clauses.join(' AND ')}` : '';
|
|
774
|
-
const rows = this.db.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail
|
|
858
|
+
const rows = this.db.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
|
|
859
|
+
credential_id, cost_usd_micros, model,
|
|
860
|
+
ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros
|
|
775
861
|
FROM activity_events
|
|
776
862
|
${where}
|
|
777
863
|
ORDER BY id DESC
|
|
@@ -786,13 +872,106 @@ export class Store {
|
|
|
786
872
|
solverType: r.solver_type,
|
|
787
873
|
outcome: r.outcome,
|
|
788
874
|
detail: r.detail,
|
|
875
|
+
credentialId: r.credential_id,
|
|
876
|
+
costUsdMicros: r.cost_usd_micros,
|
|
877
|
+
model: r.model,
|
|
878
|
+
aiUnits: r.ai_units,
|
|
879
|
+
claimStatus: r.claim_status,
|
|
880
|
+
estimatedCostUsdMicros: r.estimated_cost_usd_micros,
|
|
881
|
+
actualCostUsdMicros: r.actual_cost_usd_micros,
|
|
789
882
|
}));
|
|
790
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Total cost in micro-dollars recorded against a credential since the most
|
|
886
|
+
* recent UTC midnight. Backs the daily spend cap.
|
|
887
|
+
*/
|
|
888
|
+
spentTodayMicros(credentialId, now = new Date()) {
|
|
889
|
+
const midnight = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())).toISOString();
|
|
890
|
+
const row = this.db.prepare(`SELECT COALESCE(SUM(cost_usd_micros), 0) AS total
|
|
891
|
+
FROM activity_events
|
|
892
|
+
WHERE credential_id = @cid AND ts IS NOT NULL AND ts >= @midnight`).get({ cid: credentialId, midnight });
|
|
893
|
+
return row.total;
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Sum of `ai_units` for a credential within the current 6h UTC-aligned
|
|
897
|
+
* block (00:00 / 06:00 / 12:00 / 18:00 boundaries). Reads only rows whose
|
|
898
|
+
* `claim_status = 'claimed'` or `'delivered'` so failed-claim rows
|
|
899
|
+
* (`ai_units = 0`, `claim_status = 'claim_failed'`) don't muddy the sum
|
|
900
|
+
* even though their contribution is already zero.
|
|
901
|
+
*
|
|
902
|
+
* Issue #815. Backs the per-block AI-units ceiling gate.
|
|
903
|
+
*/
|
|
904
|
+
aiUnitsThisBlock(credentialId, now = new Date()) {
|
|
905
|
+
const startOfDay = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
|
|
906
|
+
const sinceDayStart = now.getTime() - startOfDay;
|
|
907
|
+
const sixHoursMs = 6 * 60 * 60 * 1_000;
|
|
908
|
+
// Cap at 3 — there are 4 blocks per day (indices 0..3). Edge cases
|
|
909
|
+
// where sinceDayStart ≈ 24h (millisecond rounding) would otherwise
|
|
910
|
+
// overshoot into a non-existent 5th block in the *next* day.
|
|
911
|
+
const blocksIn = Math.min(Math.floor(sinceDayStart / sixHoursMs), 3);
|
|
912
|
+
const blockStart = new Date(startOfDay + blocksIn * sixHoursMs).toISOString();
|
|
913
|
+
const blockEnd = new Date(startOfDay + (blocksIn + 1) * sixHoursMs).toISOString();
|
|
914
|
+
const row = this.db.prepare(`SELECT COALESCE(SUM(ai_units), 0) AS total
|
|
915
|
+
FROM activity_events
|
|
916
|
+
WHERE credential_id = @cid
|
|
917
|
+
AND ts IS NOT NULL AND ts >= @blockStart AND ts < @blockEnd
|
|
918
|
+
AND claim_status IN ('claimed', 'delivered')`).get({ cid: credentialId, blockStart, blockEnd });
|
|
919
|
+
return row.total ?? 0;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Sum of `ai_units` for a credential within the trailing 7-day rolling
|
|
923
|
+
* window from `now`. Backs the per-week AI-units safety-net ceiling.
|
|
924
|
+
* Issue #815.
|
|
925
|
+
*/
|
|
926
|
+
aiUnitsThisWeek(credentialId, now = new Date()) {
|
|
927
|
+
const weekStart = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1_000).toISOString();
|
|
928
|
+
const row = this.db.prepare(`SELECT COALESCE(SUM(ai_units), 0) AS total
|
|
929
|
+
FROM activity_events
|
|
930
|
+
WHERE credential_id = @cid
|
|
931
|
+
AND ts IS NOT NULL AND ts >= @weekStart
|
|
932
|
+
AND claim_status IN ('claimed', 'delivered')`).get({ cid: credentialId, weekStart });
|
|
933
|
+
return row.total ?? 0;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* True iff an `ai_units_cap_reached` row exists for the given
|
|
937
|
+
* (credentialId, window, blockId). Used by the daemon to hydrate the
|
|
938
|
+
* AI-units gate's in-memory pause memo across restarts so the
|
|
939
|
+
* "exactly one event per (credential, window, block-id)" guarantee
|
|
940
|
+
* holds across process boundaries (issue #815, finding 1).
|
|
941
|
+
*
|
|
942
|
+
* Lookup is by `credential_id` + `kind` + the `[block=...][window=...]`
|
|
943
|
+
* markers that `daemon.ts` embeds in the row's `detail` string.
|
|
944
|
+
*/
|
|
945
|
+
hasAiUnitsCapReachedFor(credentialId, window, blockId) {
|
|
946
|
+
const marker = `[block=${blockId}][window=${window}]`;
|
|
947
|
+
const row = this.db.prepare(`SELECT 1 AS hit
|
|
948
|
+
FROM activity_events
|
|
949
|
+
WHERE kind = 'ai_units_cap_reached'
|
|
950
|
+
AND credential_id = @cid
|
|
951
|
+
AND detail LIKE @marker
|
|
952
|
+
LIMIT 1`).get({ cid: credentialId, marker: `${marker}%` });
|
|
953
|
+
return row !== undefined;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Mark the per-request `claimed` row as `delivered` and record
|
|
957
|
+
* `actual_cost_usd_micros`. The `ai_units` projection captured at
|
|
958
|
+
* claim time is intentionally NOT recomputed — the issue spec says
|
|
959
|
+
* "estimates are the gate input, never recomputed". Idempotent: a
|
|
960
|
+
* no-op when no `claimed` row exists.
|
|
961
|
+
*/
|
|
962
|
+
finalizeClaimDelivered(requestId, actualCostUsdMicros) {
|
|
963
|
+
this.db.prepare(`UPDATE activity_events
|
|
964
|
+
SET claim_status = 'delivered',
|
|
965
|
+
actual_cost_usd_micros = @actual
|
|
966
|
+
WHERE request_id = @req AND claim_status = 'claimed'`).run({ req: requestId, actual: actualCostUsdMicros });
|
|
967
|
+
}
|
|
791
968
|
/** Newer events first, then ascending id for `jinn logs --follow` (oldest in batch printed first in caller). */
|
|
792
969
|
getActivityEventsAfterId(afterId, limit) {
|
|
793
970
|
const effectiveLimit = Math.max(0, Math.min(limit, 1000));
|
|
794
971
|
const rows = this.db
|
|
795
|
-
.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail
|
|
972
|
+
.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
|
|
973
|
+
credential_id, cost_usd_micros, model,
|
|
974
|
+
ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros
|
|
796
975
|
FROM activity_events
|
|
797
976
|
WHERE id > @afterId
|
|
798
977
|
ORDER BY id ASC
|
|
@@ -808,8 +987,99 @@ export class Store {
|
|
|
808
987
|
solverType: r.solver_type,
|
|
809
988
|
outcome: r.outcome,
|
|
810
989
|
detail: r.detail,
|
|
990
|
+
credentialId: r.credential_id,
|
|
991
|
+
costUsdMicros: r.cost_usd_micros,
|
|
992
|
+
model: r.model,
|
|
993
|
+
aiUnits: r.ai_units,
|
|
994
|
+
claimStatus: r.claim_status,
|
|
995
|
+
estimatedCostUsdMicros: r.estimated_cost_usd_micros,
|
|
996
|
+
actualCostUsdMicros: r.actual_cost_usd_micros,
|
|
997
|
+
}));
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Filtered, id-cursored page of activity events for the dedicated Events
|
|
1001
|
+
* page. Newest-first.
|
|
1002
|
+
*
|
|
1003
|
+
* Cursors on `id` rather than `ts` so startup/shutdown rows with null
|
|
1004
|
+
* timestamps remain reachable.
|
|
1005
|
+
*/
|
|
1006
|
+
getActivityEventsPage(opts = {}) {
|
|
1007
|
+
const effectiveLimit = Math.max(1, Math.min(opts.limit ?? 50, 200));
|
|
1008
|
+
const clauses = [];
|
|
1009
|
+
const params = { limit: effectiveLimit };
|
|
1010
|
+
if (opts.kinds && opts.kinds.length > 0) {
|
|
1011
|
+
const placeholders = opts.kinds.map((_, i) => `@kind${i}`);
|
|
1012
|
+
clauses.push(`kind IN (${placeholders.join(', ')})`);
|
|
1013
|
+
opts.kinds.forEach((k, i) => {
|
|
1014
|
+
params[`kind${i}`] = k;
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
if (opts.outcome) {
|
|
1018
|
+
clauses.push('outcome = @outcome');
|
|
1019
|
+
params['outcome'] = opts.outcome;
|
|
1020
|
+
}
|
|
1021
|
+
if (opts.requestId) {
|
|
1022
|
+
clauses.push('request_id = @requestId');
|
|
1023
|
+
params['requestId'] = opts.requestId;
|
|
1024
|
+
}
|
|
1025
|
+
if (opts.beforeId !== undefined) {
|
|
1026
|
+
clauses.push('id < @beforeId');
|
|
1027
|
+
params['beforeId'] = opts.beforeId;
|
|
1028
|
+
}
|
|
1029
|
+
const where = clauses.length > 0 ? `WHERE ${clauses.join(' AND ')}` : '';
|
|
1030
|
+
const rows = this.db.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
|
|
1031
|
+
credential_id, cost_usd_micros, model,
|
|
1032
|
+
ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros
|
|
1033
|
+
FROM activity_events
|
|
1034
|
+
${where}
|
|
1035
|
+
ORDER BY id DESC
|
|
1036
|
+
LIMIT @limit`).all(params);
|
|
1037
|
+
return rows.map((r) => ({
|
|
1038
|
+
id: r.id,
|
|
1039
|
+
ts: r.ts,
|
|
1040
|
+
kind: r.kind,
|
|
1041
|
+
requestId: r.request_id,
|
|
1042
|
+
serviceIndex: r.service_index,
|
|
1043
|
+
txHash: r.tx_hash,
|
|
1044
|
+
solverType: r.solver_type,
|
|
1045
|
+
outcome: r.outcome,
|
|
1046
|
+
detail: r.detail,
|
|
1047
|
+
credentialId: r.credential_id,
|
|
1048
|
+
costUsdMicros: r.cost_usd_micros,
|
|
1049
|
+
model: r.model,
|
|
1050
|
+
aiUnits: r.ai_units,
|
|
1051
|
+
claimStatus: r.claim_status,
|
|
1052
|
+
estimatedCostUsdMicros: r.estimated_cost_usd_micros,
|
|
1053
|
+
actualCostUsdMicros: r.actual_cost_usd_micros,
|
|
811
1054
|
}));
|
|
812
1055
|
}
|
|
1056
|
+
getActivityEventById(id) {
|
|
1057
|
+
const r = this.db.prepare(`SELECT id, ts, kind, request_id, service_index, tx_hash, solver_type, outcome, detail,
|
|
1058
|
+
credential_id, cost_usd_micros, model,
|
|
1059
|
+
ai_units, claim_status, estimated_cost_usd_micros, actual_cost_usd_micros
|
|
1060
|
+
FROM activity_events
|
|
1061
|
+
WHERE id = ?`).get(id);
|
|
1062
|
+
if (!r)
|
|
1063
|
+
return null;
|
|
1064
|
+
return {
|
|
1065
|
+
id: r.id,
|
|
1066
|
+
ts: r.ts,
|
|
1067
|
+
kind: r.kind,
|
|
1068
|
+
requestId: r.request_id,
|
|
1069
|
+
serviceIndex: r.service_index,
|
|
1070
|
+
txHash: r.tx_hash,
|
|
1071
|
+
solverType: r.solver_type,
|
|
1072
|
+
outcome: r.outcome,
|
|
1073
|
+
detail: r.detail,
|
|
1074
|
+
credentialId: r.credential_id,
|
|
1075
|
+
costUsdMicros: r.cost_usd_micros,
|
|
1076
|
+
model: r.model,
|
|
1077
|
+
aiUnits: r.ai_units,
|
|
1078
|
+
claimStatus: r.claim_status,
|
|
1079
|
+
estimatedCostUsdMicros: r.estimated_cost_usd_micros,
|
|
1080
|
+
actualCostUsdMicros: r.actual_cost_usd_micros,
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
813
1083
|
getActivityCountsByKind() {
|
|
814
1084
|
const rows = this.db.prepare(`SELECT kind, COUNT(*) as c FROM activity_events GROUP BY kind`).all();
|
|
815
1085
|
const out = {};
|
|
@@ -1519,6 +1789,128 @@ export class Store {
|
|
|
1519
1789
|
LIMIT @limit`).all(params);
|
|
1520
1790
|
return rows.map(rowToEnvelopeProjection);
|
|
1521
1791
|
}
|
|
1792
|
+
saveErc8004Anchor(input) {
|
|
1793
|
+
this.db.prepare(`INSERT INTO erc8004_anchors
|
|
1794
|
+
(envelope_id, envelope_cid, content_kind, metadata_key, agent_id,
|
|
1795
|
+
chain_id, identity_registry_address, tx_hash, block_number,
|
|
1796
|
+
payload_hex, anchored_at)
|
|
1797
|
+
VALUES
|
|
1798
|
+
(@envelopeId, @envelopeCid, @contentKind, @metadataKey, @agentId,
|
|
1799
|
+
@chainId, @identityRegistryAddress, @txHash, @blockNumber,
|
|
1800
|
+
@payloadHex, @anchoredAt)`).run({
|
|
1801
|
+
envelopeId: input.envelopeId,
|
|
1802
|
+
envelopeCid: input.envelopeCid,
|
|
1803
|
+
contentKind: input.contentKind,
|
|
1804
|
+
metadataKey: input.metadataKey,
|
|
1805
|
+
agentId: input.agentId,
|
|
1806
|
+
chainId: input.chainId,
|
|
1807
|
+
identityRegistryAddress: input.identityRegistryAddress,
|
|
1808
|
+
txHash: input.txHash,
|
|
1809
|
+
blockNumber: input.blockNumber,
|
|
1810
|
+
payloadHex: input.payloadHex,
|
|
1811
|
+
anchoredAt: input.anchoredAt,
|
|
1812
|
+
});
|
|
1813
|
+
}
|
|
1814
|
+
listErc8004AnchorsByEnvelopeCids(envelopeCids) {
|
|
1815
|
+
if (envelopeCids.length === 0)
|
|
1816
|
+
return [];
|
|
1817
|
+
const placeholders = envelopeCids.map((_, i) => `@cid${i}`).join(', ');
|
|
1818
|
+
const params = {};
|
|
1819
|
+
envelopeCids.forEach((cid, i) => { params[`cid${i}`] = cid; });
|
|
1820
|
+
const rows = this.db.prepare(`SELECT id, envelope_id, envelope_cid, content_kind, metadata_key, agent_id,
|
|
1821
|
+
chain_id, identity_registry_address, tx_hash, block_number,
|
|
1822
|
+
payload_hex, anchored_at
|
|
1823
|
+
FROM erc8004_anchors
|
|
1824
|
+
WHERE envelope_cid IN (${placeholders})
|
|
1825
|
+
ORDER BY anchored_at ASC, id ASC`).all(params);
|
|
1826
|
+
return rows.map((r) => ({
|
|
1827
|
+
id: r.id,
|
|
1828
|
+
envelopeId: r.envelope_id,
|
|
1829
|
+
envelopeCid: r.envelope_cid,
|
|
1830
|
+
contentKind: r.content_kind,
|
|
1831
|
+
metadataKey: r.metadata_key,
|
|
1832
|
+
agentId: r.agent_id,
|
|
1833
|
+
chainId: r.chain_id,
|
|
1834
|
+
identityRegistryAddress: r.identity_registry_address,
|
|
1835
|
+
txHash: r.tx_hash,
|
|
1836
|
+
blockNumber: r.block_number,
|
|
1837
|
+
payloadHex: r.payload_hex,
|
|
1838
|
+
anchoredAt: r.anchored_at,
|
|
1839
|
+
}));
|
|
1840
|
+
}
|
|
1841
|
+
/**
|
|
1842
|
+
* Upsert one held-out eval result (issue #818). PK is
|
|
1843
|
+
* `(checkpoint_cid, slate_version, instance_id)` so a re-run overwrites.
|
|
1844
|
+
* `passed` is null for `unscorable` rows.
|
|
1845
|
+
*/
|
|
1846
|
+
recordEvalResult(args) {
|
|
1847
|
+
this.db
|
|
1848
|
+
.prepare(`INSERT INTO eval_results
|
|
1849
|
+
(checkpoint_cid, slate_hash, slate_version, instance_id, passed, unscorable, code_digest, run_at_ms, test_log_excerpt)
|
|
1850
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1851
|
+
ON CONFLICT(checkpoint_cid, slate_version, instance_id) DO UPDATE SET
|
|
1852
|
+
slate_hash = excluded.slate_hash,
|
|
1853
|
+
passed = excluded.passed,
|
|
1854
|
+
unscorable = excluded.unscorable,
|
|
1855
|
+
code_digest = excluded.code_digest,
|
|
1856
|
+
run_at_ms = excluded.run_at_ms,
|
|
1857
|
+
test_log_excerpt = excluded.test_log_excerpt`)
|
|
1858
|
+
.run(args.checkpoint_cid, args.slate_hash, args.slate_version, args.instance_id, args.unscorable ? null : args.passed ? 1 : 0, args.unscorable ? 1 : 0, args.code_digest, args.run_at_ms, args.test_log_excerpt ?? null);
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Aggregate the eval results for a (checkpoint, slate version):
|
|
1862
|
+
* `scorable` = rows with `unscorable = 0`; `passed` = scorable rows with
|
|
1863
|
+
* `passed = 1`. Unscorable rows are counted separately and never enter the
|
|
1864
|
+
* denominator. A checkpoint with no rows yields all-zero (the orchestrator
|
|
1865
|
+
* reads this to detect a not-yet-evaluated parent).
|
|
1866
|
+
*/
|
|
1867
|
+
getEvalAggregate(checkpoint_cid, slate_version) {
|
|
1868
|
+
const row = this.db
|
|
1869
|
+
.prepare(`SELECT
|
|
1870
|
+
COALESCE(SUM(CASE WHEN unscorable = 0 AND passed = 1 THEN 1 ELSE 0 END), 0) AS passed,
|
|
1871
|
+
COALESCE(SUM(CASE WHEN unscorable = 0 THEN 1 ELSE 0 END), 0) AS scorable,
|
|
1872
|
+
COALESCE(SUM(CASE WHEN unscorable = 1 THEN 1 ELSE 0 END), 0) AS unscorable
|
|
1873
|
+
FROM eval_results
|
|
1874
|
+
WHERE checkpoint_cid = ? AND slate_version = ?`)
|
|
1875
|
+
.get(checkpoint_cid, slate_version);
|
|
1876
|
+
return { passed: row.passed, scorable: row.scorable, unscorable: row.unscorable };
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Distinct `slate_hash` values recorded for a (checkpoint, slate version).
|
|
1880
|
+
* The eval orchestrator reads this to detect slate-content drift under a
|
|
1881
|
+
* stable version label — the held-out exam is only an honest before/after
|
|
1882
|
+
* when the parent and child were scored on the SAME slate content (defeating
|
|
1883
|
+
* confounder #1, task-selection). Empty when the checkpoint has no rows.
|
|
1884
|
+
*/
|
|
1885
|
+
getEvalSlateHashes(checkpoint_cid, slate_version) {
|
|
1886
|
+
const rows = this.db
|
|
1887
|
+
.prepare(`SELECT DISTINCT slate_hash
|
|
1888
|
+
FROM eval_results
|
|
1889
|
+
WHERE checkpoint_cid = ? AND slate_version = ?
|
|
1890
|
+
ORDER BY slate_hash`)
|
|
1891
|
+
.all(checkpoint_cid, slate_version);
|
|
1892
|
+
return rows.map((r) => r.slate_hash);
|
|
1893
|
+
}
|
|
1894
|
+
/** Per-task eval results for a (checkpoint, slate version), ordered by instance_id. */
|
|
1895
|
+
getEvalResults(checkpoint_cid, slate_version) {
|
|
1896
|
+
const rows = this.db
|
|
1897
|
+
.prepare(`SELECT checkpoint_cid, slate_hash, slate_version, instance_id, passed, unscorable, code_digest, run_at_ms, test_log_excerpt
|
|
1898
|
+
FROM eval_results
|
|
1899
|
+
WHERE checkpoint_cid = ? AND slate_version = ?
|
|
1900
|
+
ORDER BY instance_id`)
|
|
1901
|
+
.all(checkpoint_cid, slate_version);
|
|
1902
|
+
return rows.map((r) => ({
|
|
1903
|
+
checkpoint_cid: r.checkpoint_cid,
|
|
1904
|
+
slate_hash: r.slate_hash,
|
|
1905
|
+
slate_version: r.slate_version,
|
|
1906
|
+
instance_id: r.instance_id,
|
|
1907
|
+
passed: r.passed === null ? null : r.passed === 1,
|
|
1908
|
+
unscorable: r.unscorable === 1,
|
|
1909
|
+
code_digest: r.code_digest,
|
|
1910
|
+
run_at_ms: r.run_at_ms,
|
|
1911
|
+
test_log_excerpt: r.test_log_excerpt,
|
|
1912
|
+
}));
|
|
1913
|
+
}
|
|
1522
1914
|
close() {
|
|
1523
1915
|
this.db.close();
|
|
1524
1916
|
}
|