niceeval 0.15.1-canary.76 → 0.16.1
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/INDEX.md +45 -40
- package/dist/adapter-execution-trace.cjs.map +1 -1
- package/dist/adapter-execution-trace.d.cts +26 -0
- package/dist/adapter-execution-trace.d.mts +26 -0
- package/dist/adapter-execution-trace.d.ts +26 -0
- package/dist/adapter-usage.cjs.map +1 -1
- package/dist/adapter-usage.d.cts +9 -0
- package/dist/adapter-usage.d.mts +9 -0
- package/dist/adapter-usage.d.ts +9 -0
- package/dist/adapter.cjs +19 -4
- package/dist/adapter.cjs.map +1 -1
- package/dist/adapter.d.cts +37 -12
- package/dist/adapter.d.mts +37 -12
- package/dist/adapter.d.ts +37 -12
- package/dist/agents/ai-sdk.cjs +3 -0
- package/dist/agents/ai-sdk.cjs.map +1 -1
- package/dist/agents/bub.cjs +3 -0
- package/dist/agents/bub.cjs.map +1 -1
- package/dist/agents/claude-code-native.cjs +28 -2
- package/dist/agents/claude-code-native.cjs.map +1 -1
- package/dist/agents/claude-code.cjs +3 -0
- package/dist/agents/claude-code.cjs.map +1 -1
- package/dist/agents/codex.cjs +3 -0
- package/dist/agents/codex.cjs.map +1 -1
- package/dist/agents/coding-cli-versions.cjs +9 -10
- package/dist/agents/coding-cli-versions.cjs.map +1 -1
- package/dist/agents/coding-cli-versions.d.cts +1 -1
- package/dist/agents/coding-cli-versions.d.mts +1 -1
- package/dist/agents/coding-cli-versions.d.ts +1 -1
- package/dist/agents/deepseek-harness.cjs +3 -0
- package/dist/agents/deepseek-harness.cjs.map +1 -1
- package/dist/agents/hermes.cjs +3 -0
- package/dist/agents/hermes.cjs.map +1 -1
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +3 -2
- package/dist/agents/index.d.mts +3 -2
- package/dist/agents/index.d.ts +3 -2
- package/dist/agents/omp.cjs +3 -0
- package/dist/agents/omp.cjs.map +1 -1
- package/dist/agents/openai-compat.cjs +6 -0
- package/dist/agents/openai-compat.cjs.map +1 -1
- package/dist/agents/openclaw.cjs +3 -0
- package/dist/agents/openclaw.cjs.map +1 -1
- package/dist/agents/opencode.cjs +3 -0
- package/dist/agents/opencode.cjs.map +1 -1
- package/dist/agents/sdk-streams.cjs +9 -0
- package/dist/agents/sdk-streams.cjs.map +1 -1
- package/dist/agents/ui-message-stream.cjs +3 -0
- package/dist/agents/ui-message-stream.cjs.map +1 -1
- package/dist/assertions/api.cjs.map +1 -1
- package/dist/assertions/api.d.cts +27 -5
- package/dist/assertions/api.d.mts +27 -5
- package/dist/assertions/api.d.ts +27 -5
- package/dist/assertions/collection.cjs +6 -0
- package/dist/assertions/collection.cjs.map +1 -1
- package/dist/assertions/collection.d.cts +4 -2
- package/dist/assertions/collection.d.mts +4 -2
- package/dist/assertions/collection.d.ts +4 -2
- package/dist/assertions/collection.js +12 -8
- package/dist/assertions/context-match.cjs +70 -0
- package/dist/assertions/context-match.cjs.map +1 -0
- package/dist/assertions/context-match.d.cts +107 -0
- package/dist/assertions/context-match.d.mts +107 -0
- package/dist/assertions/context-match.d.ts +107 -0
- package/dist/assertions/context-match.js +12 -0
- package/dist/assertions/context-match.js.map +1 -0
- package/dist/assertions/full-content.cjs +109 -0
- package/dist/assertions/full-content.cjs.map +1 -0
- package/dist/assertions/full-content.d.cts +6 -0
- package/dist/assertions/full-content.d.mts +6 -0
- package/dist/assertions/full-content.d.ts +6 -0
- package/dist/assertions/full-content.js +12 -0
- package/dist/assertions/full-content.js.map +1 -0
- package/dist/assertions/judge-presets.cjs +2 -34
- package/dist/assertions/judge-presets.cjs.map +1 -1
- package/dist/assertions/judge-presets.d.cts +6 -9
- package/dist/assertions/judge-presets.d.mts +6 -9
- package/dist/assertions/judge-presets.d.ts +6 -9
- package/dist/assertions/judge-presets.js +8 -8
- package/dist/assertions/judge.cjs +107 -29
- package/dist/assertions/judge.cjs.map +1 -1
- package/dist/assertions/judge.d.cts +2 -0
- package/dist/assertions/judge.d.mts +2 -0
- package/dist/assertions/judge.d.ts +2 -0
- package/dist/assertions/match.cjs +244 -5
- package/dist/assertions/match.cjs.map +1 -1
- package/dist/assertions/match.d.cts +43 -3
- package/dist/assertions/match.d.mts +43 -3
- package/dist/assertions/match.d.ts +43 -3
- package/dist/assertions/match.js +88 -78
- package/dist/assertions/material.cjs +520 -0
- package/dist/assertions/material.cjs.map +1 -0
- package/dist/assertions/material.d.cts +56 -0
- package/dist/assertions/material.d.mts +56 -0
- package/dist/assertions/material.d.ts +56 -0
- package/dist/assertions/material.js +20 -0
- package/dist/assertions/material.js.map +1 -0
- package/dist/assertions/record/attachment.cjs +5 -2
- package/dist/assertions/record/attachment.cjs.map +1 -1
- package/dist/assertions/record/codec.cjs +2 -1
- package/dist/assertions/record/codec.cjs.map +1 -1
- package/dist/assertions/record/model.cjs.map +1 -1
- package/dist/assertions/record/model.d.cts +6 -1
- package/dist/assertions/record/model.d.mts +6 -1
- package/dist/assertions/record/model.d.ts +6 -1
- package/dist/assertions/runtime.cjs +207 -14
- package/dist/assertions/runtime.cjs.map +1 -1
- package/dist/assertions/runtime.d.cts +9 -0
- package/dist/assertions/runtime.d.mts +9 -0
- package/dist/assertions/runtime.d.ts +9 -0
- package/dist/assertions/runtime.js +14 -8
- package/dist/assertions/score-match-audit.cjs +18 -8
- package/dist/assertions/score-match-audit.cjs.map +1 -1
- package/dist/assertions/score-match-gateway.cjs +83 -25
- package/dist/assertions/score-match-gateway.cjs.map +1 -1
- package/dist/assertions/score-match-gateway.d.cts +2 -0
- package/dist/assertions/score-match-gateway.d.mts +2 -0
- package/dist/assertions/score-match-gateway.d.ts +2 -0
- package/dist/assertions/value-composition.test-d.cjs +77 -0
- package/dist/assertions/value-composition.test-d.cjs.map +1 -0
- package/dist/assertions/value-composition.test-d.d.cts +1 -0
- package/dist/assertions/value-composition.test-d.d.mts +1 -0
- package/dist/assertions/value-composition.test-d.d.ts +1 -0
- package/dist/assertions/value-composition.test-d.js +4 -0
- package/dist/assertions/value-composition.test-d.js.map +1 -0
- package/dist/context/assert-first.cjs +207 -213
- package/dist/context/assert-first.cjs.map +1 -1
- package/dist/context/assert-first.d.cts +49 -23
- package/dist/context/assert-first.d.mts +49 -23
- package/dist/context/assert-first.d.ts +49 -23
- package/dist/context/session.cjs +111 -9
- package/dist/context/session.cjs.map +1 -1
- package/dist/context/session.d.cts +18 -0
- package/dist/context/session.d.mts +18 -0
- package/dist/context/session.d.ts +18 -0
- package/dist/define.cjs +17 -1
- package/dist/define.cjs.map +1 -1
- package/dist/eval/cli/contribution.cjs +2 -0
- package/dist/eval/cli/contribution.cjs.map +1 -1
- package/dist/eval/host/index.cjs +2 -0
- package/dist/eval/host/index.cjs.map +1 -1
- package/dist/eval/record/evaluation.cjs +3 -0
- package/dist/eval/record/evaluation.cjs.map +1 -1
- package/dist/eval/record/membership-provenance.d.cts +15 -15
- package/dist/eval/record/membership-provenance.d.mts +15 -15
- package/dist/eval/record/membership-provenance.d.ts +15 -15
- package/dist/eval/record/score.cjs +7 -0
- package/dist/eval/record/score.cjs.map +1 -1
- package/dist/eval/record/sealed-assertion.cjs +3 -0
- package/dist/eval/record/sealed-assertion.cjs.map +1 -1
- package/dist/eval/record/verdict.cjs +7 -0
- package/dist/eval/record/verdict.cjs.map +1 -1
- package/dist/expect/index.cjs +8 -2
- package/dist/expect/index.cjs.map +1 -1
- package/dist/expect/index.d.cts +9 -4
- package/dist/expect/index.d.mts +9 -4
- package/dist/expect/index.d.ts +9 -4
- package/dist/expect/index.js +72 -62
- package/dist/expect/index.mjs +72 -62
- package/dist/experiment/host/cli/contribution.cjs +37 -23
- package/dist/experiment/host/cli/contribution.cjs.map +1 -1
- package/dist/experiment/host/cli/contribution.d.cts +9 -1
- package/dist/experiment/host/cli/contribution.d.mts +9 -1
- package/dist/experiment/host/cli/contribution.d.ts +9 -1
- package/dist/experiment/host/current.cjs +74 -0
- package/dist/experiment/host/current.cjs.map +1 -0
- package/dist/experiment/host/current.d.cts +33 -0
- package/dist/experiment/host/current.d.mts +33 -0
- package/dist/experiment/host/current.d.ts +33 -0
- package/dist/experiment/host/current.js +10 -0
- package/dist/experiment/host/current.js.map +1 -0
- package/dist/experiment/host/index.cjs +17 -174
- package/dist/experiment/host/index.cjs.map +1 -1
- package/dist/experiment/host/index.d.cts +8 -54
- package/dist/experiment/host/index.d.mts +8 -54
- package/dist/experiment/host/index.d.ts +8 -54
- package/dist/experiment/host/operations.cjs +33 -10
- package/dist/experiment/host/operations.cjs.map +1 -1
- package/dist/experiment/host/operations.d.cts +29 -1
- package/dist/experiment/host/operations.d.mts +29 -1
- package/dist/experiment/host/operations.d.ts +29 -1
- package/dist/experiment/host/operations.js +6 -4
- package/dist/experiment/host/requirements.cjs +3 -0
- package/dist/experiment/host/requirements.cjs.map +1 -0
- package/dist/experiment/host/requirements.d.cts +3 -0
- package/dist/experiment/host/requirements.d.mts +3 -0
- package/dist/experiment/host/requirements.d.ts +3 -0
- package/dist/experiment/host/requirements.js +4 -0
- package/dist/experiment/host/requirements.js.map +1 -0
- package/dist/experiment/host/runtime.cjs +179 -0
- package/dist/experiment/host/runtime.cjs.map +1 -0
- package/dist/experiment/host/runtime.d.cts +79 -0
- package/dist/experiment/host/runtime.d.mts +79 -0
- package/dist/experiment/host/runtime.d.ts +79 -0
- package/dist/experiment/host/runtime.js +6 -0
- package/dist/experiment/host/runtime.js.map +1 -0
- package/dist/experiment/host/types.cjs.map +1 -1
- package/dist/experiment/host/types.d.cts +17 -16
- package/dist/experiment/host/types.d.mts +17 -16
- package/dist/experiment/host/types.d.ts +17 -16
- package/dist/fresh-import.cjs +2 -1
- package/dist/fresh-import.cjs.map +1 -1
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -6
- package/dist/index.d.mts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.js +32 -30
- package/dist/index.mjs +32 -30
- package/dist/inspection/artifacts.cjs +83 -54
- package/dist/inspection/artifacts.cjs.map +1 -1
- package/dist/inspection/artifacts.d.cts +8 -0
- package/dist/inspection/artifacts.d.mts +8 -0
- package/dist/inspection/artifacts.d.ts +8 -0
- package/dist/inspection/artifacts.js +2 -0
- package/dist/inspection/assertions.cjs +4 -1
- package/dist/inspection/assertions.cjs.map +1 -1
- package/dist/inspection/cli/contribution.cjs +27 -4
- package/dist/inspection/cli/contribution.cjs.map +1 -1
- package/dist/inspection/cli/contribution.d.cts +2 -1
- package/dist/inspection/cli/contribution.d.mts +2 -1
- package/dist/inspection/cli/contribution.d.ts +2 -1
- package/dist/inspection/execution-traces.cjs +114 -8
- package/dist/inspection/execution-traces.cjs.map +1 -1
- package/dist/inspection/execution-traces.d.cts +38 -0
- package/dist/inspection/execution-traces.d.mts +38 -0
- package/dist/inspection/execution-traces.d.ts +38 -0
- package/dist/inspection/facts.cjs +12 -0
- package/dist/inspection/facts.cjs.map +1 -1
- package/dist/inspection/limits.cjs +5 -1
- package/dist/inspection/limits.cjs.map +1 -1
- package/dist/inspection/limits.d.cts +4 -0
- package/dist/inspection/limits.d.mts +4 -0
- package/dist/inspection/limits.d.ts +4 -0
- package/dist/inspection/limits.js +6 -2
- package/dist/inspection/overview.cjs +74 -33
- package/dist/inspection/overview.cjs.map +1 -1
- package/dist/inspection/overview.d.cts +19 -1
- package/dist/inspection/overview.d.mts +19 -1
- package/dist/inspection/overview.d.ts +19 -1
- package/dist/inspection/overview.js +4 -2
- package/dist/inspection/project-input.cjs +9 -0
- package/dist/inspection/project-input.cjs.map +1 -0
- package/dist/inspection/project-input.d.cts +20 -0
- package/dist/inspection/project-input.d.mts +20 -0
- package/dist/inspection/project-input.d.ts +20 -0
- package/dist/inspection/project-input.js +8 -0
- package/dist/inspection/project-input.js.map +1 -0
- package/dist/inspection/project-result.cjs +60 -0
- package/dist/inspection/project-result.cjs.map +1 -0
- package/dist/inspection/project-result.d.cts +1264 -0
- package/dist/inspection/project-result.d.mts +1264 -0
- package/dist/inspection/project-result.d.ts +1264 -0
- package/dist/inspection/project-result.js +10 -0
- package/dist/inspection/project-result.js.map +1 -0
- package/dist/inspection/project-source.cjs +109 -0
- package/dist/inspection/project-source.cjs.map +1 -0
- package/dist/inspection/project-source.d.cts +10 -0
- package/dist/inspection/project-source.d.mts +10 -0
- package/dist/inspection/project-source.d.ts +10 -0
- package/dist/inspection/project-source.js +6 -0
- package/dist/inspection/project-source.js.map +1 -0
- package/dist/inspection/project.cjs +100 -0
- package/dist/inspection/project.cjs.map +1 -0
- package/dist/inspection/project.d.cts +3 -0
- package/dist/inspection/project.d.mts +3 -0
- package/dist/inspection/project.d.ts +3 -0
- package/dist/inspection/project.js +6 -0
- package/dist/inspection/project.js.map +1 -0
- package/dist/inspection/protocol.cjs +19 -9
- package/dist/inspection/protocol.cjs.map +1 -1
- package/dist/inspection/protocol.d.cts +5506 -38189
- package/dist/inspection/protocol.d.mts +5506 -38189
- package/dist/inspection/protocol.d.ts +5506 -38189
- package/dist/inspection/public.mjs +896 -84
- package/dist/inspection/query.cjs +2 -0
- package/dist/inspection/query.cjs.map +1 -1
- package/dist/inspection/results.cjs +234 -29
- package/dist/inspection/results.cjs.map +1 -1
- package/dist/inspection/results.d.cts +870 -13
- package/dist/inspection/results.d.mts +870 -13
- package/dist/inspection/results.d.ts +870 -13
- package/dist/inspection/results.js +36 -34
- package/dist/inspection/select.cjs +126 -14
- package/dist/inspection/select.cjs.map +1 -1
- package/dist/inspection/select.d.cts +1 -1
- package/dist/inspection/select.d.mts +1 -1
- package/dist/inspection/select.d.ts +1 -1
- package/dist/inspection/source.cjs +4 -0
- package/dist/inspection/source.cjs.map +1 -1
- package/dist/inspection/sources.cjs +5 -0
- package/dist/inspection/sources.cjs.map +1 -1
- package/dist/inspection/trace.cjs +82 -84
- package/dist/inspection/trace.cjs.map +1 -1
- package/dist/inspection/trace.d.cts +7 -2
- package/dist/inspection/trace.d.mts +7 -2
- package/dist/inspection/trace.d.ts +7 -2
- package/dist/model-slots.cjs +35 -0
- package/dist/model-slots.cjs.map +1 -0
- package/dist/model-slots.d.cts +19 -0
- package/dist/model-slots.d.mts +19 -0
- package/dist/model-slots.d.ts +19 -0
- package/dist/model-slots.js +8 -0
- package/dist/model-slots.js.map +1 -0
- package/dist/o11y/adapter-call-price.cjs +4 -0
- package/dist/o11y/adapter-call-price.cjs.map +1 -1
- package/dist/o11y/adapter-call-price.d.cts +24 -0
- package/dist/o11y/adapter-call-price.d.mts +24 -0
- package/dist/o11y/adapter-call-price.d.ts +24 -0
- package/dist/o11y/adapter-call-price.js +6 -2
- package/dist/o11y/adapter-usage-projection.cjs +158 -0
- package/dist/o11y/adapter-usage-projection.cjs.map +1 -0
- package/dist/o11y/adapter-usage-projection.d.cts +141 -0
- package/dist/o11y/adapter-usage-projection.d.mts +141 -0
- package/dist/o11y/adapter-usage-projection.d.ts +141 -0
- package/dist/o11y/adapter-usage-projection.js +20 -0
- package/dist/o11y/adapter-usage-projection.js.map +1 -0
- package/dist/o11y/eval-usage.cjs +149 -0
- package/dist/o11y/eval-usage.cjs.map +1 -0
- package/dist/o11y/eval-usage.d.cts +46 -0
- package/dist/o11y/eval-usage.d.mts +46 -0
- package/dist/o11y/eval-usage.d.ts +46 -0
- package/dist/o11y/eval-usage.js +8 -0
- package/dist/o11y/eval-usage.js.map +1 -0
- package/dist/o11y/judge-call-price.cjs +62 -0
- package/dist/o11y/judge-call-price.cjs.map +1 -0
- package/dist/o11y/judge-call-price.d.cts +3 -0
- package/dist/o11y/judge-call-price.d.mts +3 -0
- package/dist/o11y/judge-call-price.d.ts +3 -0
- package/dist/o11y/judge-call-price.js +6 -0
- package/dist/o11y/judge-call-price.js.map +1 -0
- package/dist/o11y/judge-usage-projection.cjs +134 -0
- package/dist/o11y/judge-usage-projection.cjs.map +1 -0
- package/dist/o11y/judge-usage-projection.d.cts +18 -0
- package/dist/o11y/judge-usage-projection.d.mts +18 -0
- package/dist/o11y/judge-usage-projection.d.ts +18 -0
- package/dist/o11y/judge-usage-projection.js +20 -0
- package/dist/o11y/judge-usage-projection.js.map +1 -0
- package/dist/o11y/judge-usage-receipt.cjs +135 -0
- package/dist/o11y/judge-usage-receipt.cjs.map +1 -0
- package/dist/o11y/judge-usage-receipt.d.cts +5 -0
- package/dist/o11y/judge-usage-receipt.d.mts +5 -0
- package/dist/o11y/judge-usage-receipt.d.ts +5 -0
- package/dist/o11y/judge-usage-receipt.js +6 -0
- package/dist/o11y/judge-usage-receipt.js.map +1 -0
- package/dist/o11y/judge-usage.cjs +171 -0
- package/dist/o11y/judge-usage.cjs.map +1 -0
- package/dist/o11y/judge-usage.d.cts +35 -0
- package/dist/o11y/judge-usage.d.mts +35 -0
- package/dist/o11y/judge-usage.d.ts +35 -0
- package/dist/o11y/judge-usage.js +6 -0
- package/dist/o11y/judge-usage.js.map +1 -0
- package/dist/plugin/contracts.cjs +2 -0
- package/dist/plugin/contracts.cjs.map +1 -1
- package/dist/plugin/link.cjs +7 -0
- package/dist/plugin/link.cjs.map +1 -1
- package/dist/record/attachment/protocol.cjs +8 -6
- package/dist/record/attachment/protocol.cjs.map +1 -1
- package/dist/record/attachment/protocol.d.cts +10 -0
- package/dist/record/attachment/protocol.d.mts +10 -0
- package/dist/record/attachment/protocol.d.ts +10 -0
- package/dist/record/attachment/protocol.js +38 -36
- package/dist/record/codec/seal-manifest.d.cts +3 -3
- package/dist/record/codec/seal-manifest.d.mts +3 -3
- package/dist/record/codec/seal-manifest.d.ts +3 -3
- package/dist/record/family/adapter-usage/definition.d.cts +1 -0
- package/dist/record/family/adapter-usage/definition.d.mts +1 -0
- package/dist/record/family/adapter-usage/definition.d.ts +1 -0
- package/dist/record/family/adapter-usage/persistence.cjs +1 -1
- package/dist/record/family/adapter-usage/persistence.cjs.map +1 -1
- package/dist/record/family/adapter-usage/persistence.d.cts +2 -1
- package/dist/record/family/adapter-usage/persistence.d.mts +2 -1
- package/dist/record/family/adapter-usage/persistence.d.ts +2 -1
- package/dist/record/family/adapter-usage/schema.cjs +21 -2
- package/dist/record/family/adapter-usage/schema.cjs.map +1 -1
- package/dist/record/family/adapter-usage/schema.d.cts +85 -0
- package/dist/record/family/adapter-usage/schema.d.mts +85 -0
- package/dist/record/family/adapter-usage/schema.d.ts +85 -0
- package/dist/record/family/adapter-usage/schema.js +18 -12
- package/dist/record/family/catalog.cjs +31 -27
- package/dist/record/family/catalog.cjs.map +1 -1
- package/dist/record/family/catalog.d.cts +94 -3
- package/dist/record/family/catalog.d.mts +94 -3
- package/dist/record/family/catalog.d.ts +94 -3
- package/dist/record/family/current.cjs +45 -42
- package/dist/record/family/current.cjs.map +1 -1
- package/dist/record/family/current.d.cts +240 -1
- package/dist/record/family/current.d.mts +240 -1
- package/dist/record/family/current.d.ts +240 -1
- package/dist/record/family/execution-traces/definition.d.cts +26 -0
- package/dist/record/family/execution-traces/definition.d.mts +26 -0
- package/dist/record/family/execution-traces/definition.d.ts +26 -0
- package/dist/record/family/execution-traces/definition.js +20 -14
- package/dist/record/family/execution-traces/schema.cjs +57 -1
- package/dist/record/family/execution-traces/schema.cjs.map +1 -1
- package/dist/record/family/execution-traces/schema.d.cts +114 -0
- package/dist/record/family/execution-traces/schema.d.mts +114 -0
- package/dist/record/family/execution-traces/schema.d.ts +114 -0
- package/dist/record/family/execution-traces/schema.js +18 -12
- package/dist/record/family/judge-usage/definition.cjs +12 -0
- package/dist/record/family/judge-usage/definition.cjs.map +1 -0
- package/dist/record/family/judge-usage/definition.d.cts +91 -0
- package/dist/record/family/judge-usage/definition.d.mts +91 -0
- package/dist/record/family/judge-usage/definition.d.ts +91 -0
- package/dist/record/family/judge-usage/definition.js +6 -0
- package/dist/record/family/judge-usage/definition.js.map +1 -0
- package/dist/record/family/judge-usage/persistence.cjs +10 -0
- package/dist/record/family/judge-usage/persistence.cjs.map +1 -0
- package/dist/record/family/judge-usage/persistence.d.cts +91 -0
- package/dist/record/family/judge-usage/persistence.d.mts +91 -0
- package/dist/record/family/judge-usage/persistence.d.ts +91 -0
- package/dist/record/family/judge-usage/persistence.js +6 -0
- package/dist/record/family/judge-usage/persistence.js.map +1 -0
- package/dist/record/family/judge-usage/schema.cjs +307 -0
- package/dist/record/family/judge-usage/schema.cjs.map +1 -0
- package/dist/record/family/judge-usage/schema.d.cts +351 -0
- package/dist/record/family/judge-usage/schema.d.mts +351 -0
- package/dist/record/family/judge-usage/schema.d.ts +351 -0
- package/dist/record/family/judge-usage/schema.js +18 -0
- package/dist/record/family/judge-usage/schema.js.map +1 -0
- package/dist/record/host/sqlite-host.cjs +55 -9
- package/dist/record/host/sqlite-host.cjs.map +1 -1
- package/dist/record/host/types.cjs.map +1 -1
- package/dist/record/host/types.d.cts +7 -0
- package/dist/record/host/types.d.mts +7 -0
- package/dist/record/host/types.d.ts +7 -0
- package/dist/record/model/run-context.cjs +7 -1
- package/dist/record/model/run-context.cjs.map +1 -1
- package/dist/record/model/run-context.d.cts +4 -0
- package/dist/record/model/run-context.d.mts +4 -0
- package/dist/record/model/run-context.d.ts +4 -0
- package/dist/record/model/seal-manifest.d.cts +1 -1
- package/dist/record/model/seal-manifest.d.mts +1 -1
- package/dist/record/model/seal-manifest.d.ts +1 -1
- package/dist/record/sqlite/client.cjs +18 -5
- package/dist/record/sqlite/client.cjs.map +1 -1
- package/dist/record/sqlite/client.d.cts +1 -1
- package/dist/record/sqlite/client.d.mts +1 -1
- package/dist/record/sqlite/client.d.ts +1 -1
- package/dist/record/sqlite/project-state-database.cjs +29 -8
- package/dist/record/sqlite/project-state-database.cjs.map +1 -1
- package/dist/run/host/runtime.cjs +4 -0
- package/dist/run/host/runtime.cjs.map +1 -1
- package/dist/run/storage/sqlite.cjs +20 -0
- package/dist/run/storage/sqlite.cjs.map +1 -1
- package/dist/runner/adapter-execution-trace.cjs +125 -2
- package/dist/runner/adapter-execution-trace.cjs.map +1 -1
- package/dist/runner/adapter-execution-trace.d.cts +1 -1
- package/dist/runner/adapter-execution-trace.d.mts +1 -1
- package/dist/runner/adapter-execution-trace.d.ts +1 -1
- package/dist/runner/adapter-usage.cjs +55 -7
- package/dist/runner/adapter-usage.cjs.map +1 -1
- package/dist/runner/adapter-usage.d.cts +9 -2
- package/dist/runner/adapter-usage.d.mts +9 -2
- package/dist/runner/adapter-usage.d.ts +9 -2
- package/dist/runner/adoption.cjs +9 -0
- package/dist/runner/adoption.cjs.map +1 -1
- package/dist/runner/attempt-cancellation.cjs +12 -0
- package/dist/runner/attempt-cancellation.cjs.map +1 -0
- package/dist/runner/attempt-cancellation.d.cts +6 -0
- package/dist/runner/attempt-cancellation.d.mts +6 -0
- package/dist/runner/attempt-cancellation.d.ts +6 -0
- package/dist/runner/attempt-cancellation.js +6 -0
- package/dist/runner/attempt-cancellation.js.map +1 -0
- package/dist/runner/attempt-resources.cjs +10 -4
- package/dist/runner/attempt-resources.cjs.map +1 -1
- package/dist/runner/attempt-resources.d.cts +2 -1
- package/dist/runner/attempt-resources.d.mts +2 -1
- package/dist/runner/attempt-resources.d.ts +2 -1
- package/dist/runner/attempt.cjs +1177 -1139
- package/dist/runner/attempt.cjs.map +1 -1
- package/dist/runner/config-identity.cjs +20 -1
- package/dist/runner/config-identity.cjs.map +1 -1
- package/dist/runner/config-identity.d.cts +5 -0
- package/dist/runner/config-identity.d.mts +5 -0
- package/dist/runner/config-identity.d.ts +5 -0
- package/dist/runner/discover.cjs +14 -0
- package/dist/runner/discover.cjs.map +1 -1
- package/dist/runner/discover.d.cts +3 -0
- package/dist/runner/discover.d.mts +3 -0
- package/dist/runner/discover.d.ts +3 -0
- package/dist/runner/feedback/human.cjs +9 -4
- package/dist/runner/feedback/human.cjs.map +1 -1
- package/dist/runner/fingerprint.cjs +1 -0
- package/dist/runner/fingerprint.cjs.map +1 -1
- package/dist/runner/judge-usage.cjs +18 -0
- package/dist/runner/judge-usage.cjs.map +1 -0
- package/dist/runner/judge-usage.d.cts +5 -0
- package/dist/runner/judge-usage.d.mts +5 -0
- package/dist/runner/judge-usage.d.ts +5 -0
- package/dist/runner/judge-usage.js +8 -0
- package/dist/runner/judge-usage.js.map +1 -0
- package/dist/runner/project-target.cjs.map +1 -1
- package/dist/runner/project-target.d.cts +2 -0
- package/dist/runner/project-target.d.mts +2 -0
- package/dist/runner/project-target.d.ts +2 -0
- package/dist/runner/record/planning.cjs +1 -0
- package/dist/runner/record/planning.cjs.map +1 -1
- package/dist/runner/record.cjs +4 -0
- package/dist/runner/record.cjs.map +1 -1
- package/dist/runner/reporters/braintrust.cjs +2 -0
- package/dist/runner/reporters/braintrust.cjs.map +1 -1
- package/dist/runner/reuse-diagnostics.cjs +9 -10
- package/dist/runner/reuse-diagnostics.cjs.map +1 -1
- package/dist/runner/reuse-diagnostics.d.cts +5 -6
- package/dist/runner/reuse-diagnostics.d.mts +5 -6
- package/dist/runner/reuse-diagnostics.d.ts +5 -6
- package/dist/runner/reuse-diagnostics.js +4 -4
- package/dist/runner/reuse-plan.cjs +100 -48
- package/dist/runner/reuse-plan.cjs.map +1 -1
- package/dist/runner/reuse-plan.d.cts +60 -3
- package/dist/runner/reuse-plan.d.mts +60 -3
- package/dist/runner/reuse-plan.d.ts +60 -3
- package/dist/runner/reuse-plan.js +14 -10
- package/dist/runner/run.cjs +8 -6
- package/dist/runner/run.cjs.map +1 -1
- package/dist/runner/session.cjs +1 -1
- package/dist/runner/session.cjs.map +1 -1
- package/dist/runner/session.d.cts +1 -1
- package/dist/runner/session.d.mts +1 -1
- package/dist/runner/session.d.ts +1 -1
- package/dist/runner/source-producer.cjs +3 -1
- package/dist/runner/source-producer.cjs.map +1 -1
- package/dist/runner/types.cjs.map +1 -1
- package/dist/runner/types.d.cts +26 -5
- package/dist/runner/types.d.mts +26 -5
- package/dist/runner/types.d.ts +26 -5
- package/dist/sandbox/action.cjs +3 -0
- package/dist/sandbox/action.cjs.map +1 -1
- package/dist/sandbox/commands.cjs +3 -0
- package/dist/sandbox/commands.cjs.map +1 -1
- package/dist/sandbox/compose.cjs +6 -0
- package/dist/sandbox/compose.cjs.map +1 -1
- package/dist/sandbox/docker-profile/registry.cjs +7 -0
- package/dist/sandbox/docker-profile/registry.cjs.map +1 -1
- package/dist/sandbox/docker-profile/runtime.cjs +3 -0
- package/dist/sandbox/docker-profile/runtime.cjs.map +1 -1
- package/dist/sandbox/docker-profile/schema.cjs +7 -0
- package/dist/sandbox/docker-profile/schema.cjs.map +1 -1
- package/dist/sandbox/incus.cjs +7 -0
- package/dist/sandbox/incus.cjs.map +1 -1
- package/dist/sandbox/layer.cjs +12 -0
- package/dist/sandbox/layer.cjs.map +1 -1
- package/dist/shared/adapter-cleanup.cjs +18 -0
- package/dist/shared/adapter-cleanup.cjs.map +1 -0
- package/dist/shared/adapter-cleanup.d.cts +4 -0
- package/dist/shared/adapter-cleanup.d.mts +4 -0
- package/dist/shared/adapter-cleanup.d.ts +4 -0
- package/dist/shared/adapter-cleanup.js +10 -0
- package/dist/shared/adapter-cleanup.js.map +1 -0
- package/dist/shared/attempt-lifecycle.cjs +3 -0
- package/dist/shared/attempt-lifecycle.cjs.map +1 -0
- package/dist/shared/attempt-lifecycle.d.cts +13 -0
- package/dist/shared/attempt-lifecycle.d.mts +13 -0
- package/dist/shared/attempt-lifecycle.d.ts +13 -0
- package/dist/shared/attempt-lifecycle.js +4 -0
- package/dist/shared/attempt-lifecycle.js.map +1 -0
- package/dist/show/contribution.cjs +52 -14
- package/dist/show/contribution.cjs.map +1 -1
- package/dist/show/contribution.d.cts +23 -1
- package/dist/show/contribution.d.mts +23 -1
- package/dist/show/contribution.d.ts +23 -1
- package/dist/show/model.cjs +8 -1
- package/dist/show/model.cjs.map +1 -1
- package/dist/show/model.d.cts +10 -1
- package/dist/show/model.d.mts +10 -1
- package/dist/show/model.d.ts +10 -1
- package/dist/show/render.cjs +287 -49
- package/dist/show/render.cjs.map +1 -1
- package/dist/show/render.d.cts +3 -0
- package/dist/show/render.d.mts +3 -0
- package/dist/show/render.d.ts +3 -0
- package/dist/sources/projector.cjs +3 -0
- package/dist/sources/projector.cjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/view/app-dist/.vite/manifest.json +2 -2
- package/dist/view/app-dist/assets/index-CmVoXbwG.js +63 -0
- package/dist/view/app-dist/assets/{quality-cost-scatter-CFB3wnkN.js → quality-cost-scatter-BuLISaH4.js} +1 -1
- package/dist/view/app-dist/index.html +1 -1
- package/dist/view/cli/contribution.cjs +54 -21
- package/dist/view/cli/contribution.cjs.map +1 -1
- package/dist/view/cli/contribution.d.cts +2 -1
- package/dist/view/cli/contribution.d.mts +2 -1
- package/dist/view/cli/contribution.d.ts +2 -1
- package/dist/view/function-runtime.mjs +13231 -11647
- package/dist/view/http-protocol.cjs +3 -0
- package/dist/view/http-protocol.cjs.map +1 -1
- package/dist/view/http-protocol.d.cts +8 -0
- package/dist/view/http-protocol.d.mts +8 -0
- package/dist/view/http-protocol.d.ts +8 -0
- package/dist/view/inspection-host.cjs +17 -1
- package/dist/view/inspection-host.cjs.map +1 -1
- package/dist/view/render.cjs +1 -0
- package/dist/view/render.cjs.map +1 -1
- package/dist/view/render.d.cts +2 -1
- package/dist/view/render.d.mts +2 -1
- package/dist/view/render.d.ts +2 -1
- package/dist/view/revision.cjs.map +1 -1
- package/dist/view/revision.d.cts +12 -0
- package/dist/view/revision.d.mts +12 -0
- package/dist/view/revision.d.ts +12 -0
- package/dist/view/server.cjs +10 -9
- package/dist/view/server.cjs.map +1 -1
- package/docs-site/zh/examples/ai-agent-application.mdx +1 -1
- package/docs-site/zh/explanation/adapter.mdx +2 -2
- package/docs-site/zh/explanation/assert.mdx +60 -24
- package/docs-site/zh/explanation/drive.mdx +1 -1
- package/docs-site/zh/explanation/evals.mdx +31 -29
- package/docs-site/zh/explanation/experiment.mdx +15 -15
- package/docs-site/zh/explanation/judge.mdx +23 -15
- package/docs-site/zh/explanation/overview.mdx +44 -21
- package/docs-site/zh/explanation/record.mdx +28 -13
- package/docs-site/zh/explanation/results-flow.mdx +37 -0
- package/docs-site/zh/explanation/runner.mdx +27 -6
- package/docs-site/zh/index.mdx +22 -115
- package/docs-site/zh/introduction.mdx +89 -61
- package/docs-site/zh/reference/cli.mdx +50 -26
- package/docs-site/zh/reference/define-agent.mdx +37 -5
- package/docs-site/zh/reference/define-eval.mdx +130 -29
- package/docs-site/zh/reference/define-experiment.mdx +251 -0
- package/docs-site/zh/reference/events.mdx +34 -30
- package/docs-site/zh/reference/expect.mdx +77 -2
- package/docs-site/zh/reference/official-adapters.mdx +2 -2
- package/docs-site/zh/troubleshooting/debug-sandbox.mdx +43 -24
- package/docs-site/zh/troubleshooting/debugging.mdx +65 -42
- package/docs-site/zh/troubleshooting/recover-after-kill.mdx +35 -28
- package/docs-site/zh/tutorials/accept-results.mdx +34 -24
- package/docs-site/zh/tutorials/agent-feedback-loop.mdx +74 -43
- package/docs-site/zh/tutorials/agent-onboarding.mdx +27 -20
- package/docs-site/zh/tutorials/authoring.mdx +138 -121
- package/docs-site/zh/tutorials/ci-integration.mdx +46 -22
- package/docs-site/zh/tutorials/compare-runs.mdx +40 -13
- package/docs-site/zh/tutorials/concurrency.mdx +66 -62
- package/docs-site/zh/tutorials/configuration.mdx +17 -17
- package/docs-site/zh/tutorials/connect-otel.mdx +48 -37
- package/docs-site/zh/tutorials/connect-your-agent.mdx +80 -173
- package/docs-site/zh/tutorials/control-run-cost.mdx +63 -12
- package/docs-site/zh/tutorials/criteria-files.mdx +28 -21
- package/docs-site/zh/tutorials/custom-application.mdx +75 -55
- package/docs-site/zh/tutorials/dataset-fanout.mdx +32 -22
- package/docs-site/zh/tutorials/debug-lifecycle-plan.mdx +38 -31
- package/docs-site/zh/tutorials/docker-in-docker.mdx +83 -89
- package/docs-site/zh/tutorials/eval-groups.mdx +70 -89
- package/docs-site/zh/tutorials/evaluation-kinds.mdx +12 -5
- package/docs-site/zh/tutorials/experiment-services.mdx +243 -0
- package/docs-site/zh/tutorials/fixtures.mdx +42 -26
- package/docs-site/zh/tutorials/handle-execution-failures.mdx +41 -19
- package/docs-site/zh/tutorials/install-custom-sandbox-agent.mdx +21 -16
- package/docs-site/zh/tutorials/niceeval-taste-application.mdx +394 -0
- package/docs-site/zh/tutorials/niceeval-taste.mdx +190 -0
- package/docs-site/zh/tutorials/nixos-managed-dind.mdx +51 -39
- package/docs-site/zh/tutorials/plugins.mdx +55 -31
- package/docs-site/zh/tutorials/prebuilt-sandbox.mdx +204 -0
- package/docs-site/zh/tutorials/quickstart.mdx +91 -47
- package/docs-site/zh/tutorials/reporters.mdx +45 -30
- package/docs-site/zh/tutorials/rerun-and-cache.mdx +39 -40
- package/docs-site/zh/tutorials/sandbox-agent.mdx +65 -40
- package/docs-site/zh/tutorials/sandbox-providers.mdx +104 -282
- package/docs-site/zh/tutorials/sandbox-reuse.mdx +65 -97
- package/docs-site/zh/tutorials/select-and-preview.mdx +25 -20
- package/docs-site/zh/tutorials/verify-judge.mdx +49 -26
- package/docs-site/zh/tutorials/viewing-results.mdx +130 -80
- package/docs-site/zh/tutorials/write-experiment.mdx +116 -298
- package/docs-site/zh/tutorials/write-send.mdx +53 -52
- package/node_modules/undici/docs/docs/api/Agent.md +8 -8
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
- package/node_modules/undici/docs/docs/api/Errors.md +25 -0
- package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
- package/node_modules/undici/docs/docs/api/Pool.md +5 -6
- package/node_modules/undici/lib/api/readable.js +1 -2
- package/node_modules/undici/lib/core/request.js +23 -2
- package/node_modules/undici/lib/core/util.js +0 -39
- package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
- package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
- package/node_modules/undici/lib/dispatcher/client.js +1 -1
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -2
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
- package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
- package/node_modules/undici/lib/dispatcher/pool.js +90 -7
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
- package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
- package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
- package/node_modules/undici/lib/handler/retry-handler.js +72 -13
- package/node_modules/undici/lib/interceptor/cache.js +4 -1
- package/node_modules/undici/lib/interceptor/decompress.js +236 -69
- package/node_modules/undici/lib/web/cache/cache.js +17 -8
- package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
- package/node_modules/undici/lib/web/cookies/index.js +19 -7
- package/node_modules/undici/lib/web/cookies/util.js +3 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
- package/node_modules/undici/lib/web/fetch/body.js +22 -15
- package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
- package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
- package/node_modules/undici/lib/web/fetch/headers.js +34 -31
- package/node_modules/undici/lib/web/fetch/index.js +38 -14
- package/node_modules/undici/lib/web/fetch/request.js +74 -79
- package/node_modules/undici/lib/web/fetch/response.js +43 -44
- package/node_modules/undici/lib/web/fetch/util.js +7 -7
- package/node_modules/undici/lib/web/infra/index.js +16 -1
- package/node_modules/undici/lib/web/webidl/index.js +2 -14
- package/node_modules/undici/lib/web/websocket/events.js +43 -26
- package/node_modules/undici/lib/web/websocket/receiver.js +5 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
- package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/diagnostics-channel.d.ts +2 -1
- package/node_modules/undici/types/interceptors.d.ts +1 -1
- package/node_modules/undici/types/webidl.d.ts +13 -7
- package/package.json +4 -4
- package/dist/view/app-dist/assets/index-DFzw1L97.js +0 -63
- package/docs-site/zh/tutorials/experiments.mdx +0 -101
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":";;;AAea,QAAA,mBAAmB,GAAkB,MAAM,CAAC,iCAAiC,CAAC,CAAC;AAC/E,QAAA,uBAAuB,GAAkB,MAAM,CAAC,qCAAqC,CAAC,CAAC;AACvF,QAAA,qBAAqB,GAAkB,MAAM,CAAC,mCAAmC,CAAC,CAAC;AACnF,QAAA,oBAAoB,GAAkB,MAAM,CAAC,kCAAkC,CAAC,CAAC;AACjF,QAAA,wBAAwB,GAAkB,MAAM,CAAC,sCAAsC,CAAC,CAAC","sourcesContent":["import type { Effect, Schema, Stream } from \"effect\";\nimport type { ProjectStateDatabase } from \"../sqlite/project-state-database.ts\";\nimport type { RecordAttachmentCatalog, RecordAttachmentDefinition, } from \"../attachment/index.ts\";\nimport type { RecordContentHandle, RecordTextContentHandle, } from \"../attachment/content.ts\";\nimport type { AttachedContentError, AttachedContentRequirements, RecordAttachmentSessionBuilder, } from \"../writer/current-attachment.ts\";\nimport type { AttemptDocument, MemberDocument, RecordAttachmentOwner, RecordSlotIdentity, RunDocument, } from \"../model/core.ts\";\nimport type { RunContext } from \"../model/run-context.ts\";\nimport type { AttemptId, ExperimentId, RunId, SlotId, UtcMillis, } from \"../model/identifiers.ts\";\nimport type { RecordRoot } from \"../platform/root.ts\";\nimport type { RunAbsenceReason } from \"../../run/protocol.ts\";\nimport type { RecordAttachmentRead as ModelRecordAttachmentRead, RecordCoreRead, RecordWarning, } from \"../model/read-state.ts\";\nimport type { RecordMaintenanceError, RecordMaintenanceOpenError, RecordCompletenessError, RecordReaderOpenError, RecordReaderReadError, } from \"../reader/errors.ts\";\nimport type { RecordWriteError } from \"../writer/types.ts\";\nimport type { RecordFileSystemError } from \"../platform/errors.ts\";\nimport type { AnyRecordDefinition, AttemptRecordAppendCommand, AttemptRecordAppendReceipt, AttemptRecordCollectionLimitation, AttemptRecordCollectionDefinition, RecordDefinitionValue, RecordWriteCommand, } from \"../authoring.ts\";\nexport const selectedRunRefBrand: unique symbol = Symbol(\"@niceeval/record/SelectedRunRef\");\nexport const selectedAttemptRefBrand: unique symbol = Symbol(\"@niceeval/record/SelectedAttemptRef\");\nexport const selectedOwnerRefBrand: unique symbol = Symbol(\"@niceeval/record/SelectedOwnerRef\");\nexport const runWriteSessionBrand: unique symbol = Symbol(\"@niceeval/record/RunWriteSession\");\nexport const attemptWriteSessionBrand: unique symbol = Symbol(\"@niceeval/record/AttemptWriteSession\");\ntype AnyDefinition<Owner extends RecordAttachmentOwner = RecordAttachmentOwner> = RecordAttachmentDefinition<Owner, string, Schema.Top>;\ntype DefinitionValue<Definition extends AnyDefinition> = Schema.Schema.Type<Definition[\"schema\"]>;\n/** Nominal ref issued only by one live RecordReadSession. */\nexport interface SelectedRunRef {\n readonly runId: RunId;\n readonly [selectedRunRefBrand]: () => void;\n}\n/** Nominal exact reference to one immutable origin Attempt. */\nexport interface SelectedAttemptRef {\n readonly originRunId: RunId;\n readonly attemptId: AttemptId;\n /** Complete durable identity required before this Attempt can be referenced. */\n readonly publicationIdentity?: {\n readonly originRunId: string;\n readonly attemptId: string;\n readonly revision: number;\n };\n readonly [selectedAttemptRefBrand]: () => void;\n}\n/** Owner handle for a later catalog-authorized Attachment read. */\nexport interface SelectedOwnerRef<out Owner extends \"run\" | \"attempt\" = \"run\" | \"attempt\"> {\n readonly [selectedOwnerRefBrand]: () => void;\n /** Nominal type witness only; the actual owner identity stays Host-private. */\n readonly __owner?: () => Owner;\n}\n/**\n * The Host exposes current Attachment states without importing maintenance.\n * A reachable older revision is migration-required. Any other well-formed,\n * non-current revision remains unsupported data; malformed envelopes and\n * closures are invalid, never a reader-wide failure.\n */\nexport interface RecordAttachmentContentReader {\n /** Exact persisted byte length without loading Content bytes. */\n readonly byteLength: (handle: RecordContentHandle) => Effect.Effect<number, RecordReaderReadError>;\n readonly bytes: (handle: RecordContentHandle) => Effect.Effect<Uint8Array, RecordReaderReadError>;\n readonly text: (handle: RecordTextContentHandle) => Effect.Effect<string, RecordReaderReadError>;\n readonly stream: (handle: RecordContentHandle) => Stream.Stream<Uint8Array, RecordReaderReadError>;\n}\nexport type RecordAttachmentRead<Payload> = Exclude<ModelRecordAttachmentRead<Payload>, {\n readonly state: \"available\";\n}> | {\n readonly state: \"available\";\n /** Direct business fields from the current owner value definition. */\n readonly value: Payload;\n /** Scope-owned logical content consumption; it exposes no path or pointer. */\n readonly content: RecordAttachmentContentReader;\n};\ntype AttemptRecordCollectionRead<Payload> = Exclude<RecordAttachmentRead<Payload>, {\n readonly state: \"available\";\n}> | {\n readonly state: \"available\";\n readonly value: Payload;\n};\nexport type RecordSelectionProblem = {\n readonly code: \"incomplete-run\";\n readonly runId: RunId;\n} | {\n readonly code: \"record-core-invalid\";\n readonly runId: RunId;\n} | {\n readonly code: \"selection-run-missing\";\n readonly runId: RunId;\n};\nexport interface RecordSelectionRequest {\n /** Omitted means every terminal Run eligible for reuse during this scan. */\n readonly runIds?: readonly RunId[];\n /** Explicit locator resolution may include immutable publications from an active origin Run. */\n readonly includePublishedActive?: boolean;\n}\n/**\n * Closed Run facts verified by scanSelection. They retain the denominator\n * frame if a later member read becomes unavailable; they are not a durable\n * schema and contain no owner capability.\n */\nexport interface SelectedRunFacts {\n readonly run: SelectedRunRef;\n readonly experimentId: ExperimentId;\n readonly startedAt: UtcMillis;\n readonly completedAt: UtcMillis;\n readonly expectedSlots: readonly RecordSlotIdentity[];\n}\n/** A closed candidate set with only selected minimal Core; never Attachment payloads. */\nexport interface RecordSelection {\n readonly runRefs: readonly SelectedRunRef[];\n readonly runFacts: readonly SelectedRunFacts[];\n readonly expectedSlots: readonly {\n readonly run: SelectedRunRef;\n /** Closed at scan time from the selected Run, not stored in RecordSlotIdentity. */\n readonly experimentId: ExperimentId;\n readonly slot: RecordSlotIdentity;\n }[];\n readonly problems: readonly RecordSelectionProblem[];\n readonly warnings: readonly RecordWarning[];\n}\nexport interface ReadableRun {\n readonly createdRevision?: number;\n readonly ref: SelectedRunRef;\n readonly owner: SelectedOwnerRef<\"run\">;\n readonly document: RunDocument;\n readonly members: readonly {\n readonly document: MemberDocument;\n readonly bindingRevision?: number;\n readonly attempt: SelectedAttemptRef | null;\n }[];\n}\nexport interface ReadableAttempt {\n readonly ref: SelectedAttemptRef;\n readonly owner: SelectedOwnerRef<\"attempt\">;\n readonly document: AttemptDocument;\n /**\n * Verified while resolving the exact nominal Attempt reference. It is the\n * only origin Run Core projection Sample may use. In particular, a carried\n * or accepted member must retain this origin's execution facts rather than\n * substituting the selected target Run.\n */\n readonly origin: {\n readonly owner: SelectedOwnerRef<\"run\">;\n readonly runId: RunId;\n readonly experimentId: ExperimentId;\n readonly startedAt: UtcMillis;\n readonly context: RunContext;\n };\n}\nexport interface RecordReadSession {\n readonly selectRuns: (request?: RecordSelectionRequest) => Effect.Effect<RecordSelection, RecordReaderReadError>;\n readonly readRun: (ref: SelectedRunRef) => Effect.Effect<RecordCoreRead<ReadableRun>, RecordReaderReadError>;\n readonly readAttempt: (ref: SelectedAttemptRef) => Effect.Effect<RecordCoreRead<ReadableAttempt>, RecordReaderReadError>;\n readonly read: {\n <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>>(owner: SelectedOwnerRef<\"attempt\">, definition: Definition): Effect.Effect<AttemptRecordCollectionRead<Schema.Schema.Type<Definition[\"schema\"]>>, RecordReaderReadError>;\n <Owner extends \"run\" | \"attempt\", Definition extends AnyRecordDefinition<Owner>>(owner: SelectedOwnerRef<Owner>, definition: Definition): Effect.Effect<RecordAttachmentRead<RecordDefinitionValue<Definition>>, RecordReaderReadError>;\n <Owner extends \"run\" | \"attempt\", Definition extends AnyDefinition<Owner>>(owner: SelectedOwnerRef<Owner>, definition: Definition): Effect.Effect<RecordAttachmentRead<DefinitionValue<Definition>>, RecordReaderReadError>;\n };\n readonly openCollection: <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>>(owner: SelectedOwnerRef<\"attempt\">, definition: Definition) => Effect.Effect<Exclude<AttemptRecordCollectionRead<Schema.Schema.Type<Definition[\"schema\"]>>, {\n readonly state: \"available\";\n }> | {\n readonly state: \"available\";\n readonly collection: Schema.Schema.Type<Definition[\"schema\"]>[\"collection\"];\n readonly logicalIdentity: string;\n readonly logicalSealIdentity: string;\n readonly count: number;\n readonly digest: string;\n readonly items: Stream.Stream<Schema.Schema.Type<Definition[\"item\"]>, RecordReaderReadError>;\n }, RecordReaderReadError>;\n readonly requireComplete: (selection: RecordSelection) => Effect.Effect<RecordCompleteView, RecordCompletenessError>;\n}\n/** Complete only for this session's frozen selection and immutable catalog. */\nexport interface RecordCompleteView {\n readonly selection: RecordSelection;\n readonly attachments: RecordAttachmentCatalog;\n}\nexport interface CreateRunRequest {\n readonly root: RecordRoot;\n readonly experimentId: ExperimentId;\n /** Required historical interpretation facts, written once into `run.json`. */\n readonly context: RunContext;\n readonly startedAt: UtcMillis;\n readonly expectedSlots: readonly RecordSlotIdentity[];\n /** Host-private exact process identity used for crash recovery fencing. */\n readonly writerGeneration?: string;\n}\nexport interface CreateReferenceRunRequest extends CreateRunRequest {\n}\nexport interface RunCompletion {\n readonly completedAt: UtcMillis;\n}\nexport interface RecordSealReceipt {\n readonly runId: RunId;\n readonly state: \"sealed\";\n}\nexport interface AttemptWriteSession {\n readonly attemptId: AttemptId;\n readonly slotId: SlotId;\n readonly [attemptWriteSessionBrand]: () => void;\n readonly complete: (outcome: AttemptDocument[\"outcome\"]) => Effect.Effect<void, RecordWriteError>;\n readonly attach: OwnerAttachmentWriter<\"attempt\">;\n readonly record: AttemptRecordWriter;\n readonly records: AttemptRecordsWriter;\n}\nexport interface OwnerRecordsWriter<Owner extends \"run\" | \"attempt\"> {\n readonly write: {\n <Definition extends AnyRecordDefinition<Owner>>(definition: Definition, value: RecordDefinitionValue<Definition> | ((build: RecordAttachmentSessionBuilder) => RecordDefinitionValue<Definition>)): Effect.Effect<void, RecordWriteError | AttachedContentError<RecordDefinitionValue<Definition>>, AttachedContentRequirements<RecordDefinitionValue<Definition>>>;\n <Definition extends AnyDefinition<Owner>, Value extends DefinitionValue<Definition>>(definition: Definition, value: Value | ((build: RecordAttachmentSessionBuilder) => Value)): Effect.Effect<void, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>>;\n };\n}\nexport interface AttemptRecordsWriter extends OwnerRecordsWriter<\"attempt\"> {\n readonly append: <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>>(definition: Definition, item: Schema.Schema.Type<Definition[\"item\"]>) => Effect.Effect<AttemptRecordAppendReceipt, RecordWriteError>;\n readonly appendAll: <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>, Error, Requirements>(definition: Definition, items: Stream.Stream<Schema.Schema.Type<Definition[\"item\"]>, Error, Requirements>) => Effect.Effect<void, RecordWriteError | Error, Requirements>;\n readonly close: <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>>(definition: Definition, completion: {\n readonly state: \"complete\";\n } | {\n readonly state: \"partial\";\n readonly limitations: readonly [\n AttemptRecordCollectionLimitation,\n ...AttemptRecordCollectionLimitation[]\n ];\n }) => Effect.Effect<void, RecordWriteError>;\n}\nexport interface OwnerRecordWriter<Owner extends \"run\" | \"attempt\"> {\n readonly write: <Value, Error, Requirements>(command: RecordWriteCommand<Owner, Value, Error, Requirements>) => Effect.Effect<void, RecordWriteError | Error, Requirements>;\n}\nexport interface AttemptRecordWriter extends OwnerRecordWriter<\"attempt\"> {\n readonly start: (definition: AttemptRecordCollectionDefinition<string, Schema.Top>) => Effect.Effect<void, RecordWriteError>;\n readonly append: <Item>(command: AttemptRecordAppendCommand<Item>) => Effect.Effect<AttemptRecordAppendReceipt, RecordWriteError>;\n}\nexport interface OwnerAttachmentWriter<Owner extends \"run\" | \"attempt\"> {\n <Definition extends AnyDefinition<Owner>, Value extends DefinitionValue<Definition>>(definition: Definition, value: Value | ((build: RecordAttachmentSessionBuilder) => Value)): Effect.Effect<void, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>>;\n}\n/** One session owns exactly one freshly exclusive RunId directory. */\nexport interface RunWriteSession {\n readonly runId: RunId;\n readonly [runWriteSessionBrand]: () => void;\n readonly createAttempt: (input: {\n readonly slotId: SlotId;\n }) => Effect.Effect<AttemptWriteSession, RecordWriteError>;\n readonly referenceAttempt: (input: {\n readonly slotId: SlotId;\n readonly action: \"carried\" | \"accepted\";\n readonly attempt: SelectedAttemptRef;\n }) => Effect.Effect<void, RecordWriteError>;\n /**\n * Explicit adoption / rename: occupy one current target Slot with an already\n * selected origin Attempt. The target Slot identity may differ from the\n * origin Attempt. This is not a generic Attachment writer.\n */\n readonly recordAcceptedMembership: (input: {\n readonly slotId: SlotId;\n readonly attempt: SelectedAttemptRef;\n }) => Effect.Effect<void, RecordWriteError>;\n readonly recordTerminalMember: (input: {\n readonly slotId: SlotId;\n readonly action: \"not-dispatched\" | \"interrupted\";\n readonly absenceReason: RunAbsenceReason;\n }) => Effect.Effect<void, RecordWriteError>;\n readonly attach: OwnerAttachmentWriter<\"run\">;\n readonly record: OwnerRecordWriter<\"run\">;\n readonly records: OwnerRecordsWriter<\"run\">;\n readonly seal: (completion: RunCompletion) => Effect.Effect<RecordSealReceipt, RecordWriteError>;\n}\n/** A Run created solely from already-selected, sealed Attempts. */\nexport interface ReferenceRunWriteSession {\n readonly runId: RunId;\n readonly [runWriteSessionBrand]: () => void;\n readonly referenceAttempt: RunWriteSession[\"referenceAttempt\"];\n readonly recordAcceptedMembership: RunWriteSession[\"recordAcceptedMembership\"];\n readonly recordTerminalMember: RunWriteSession[\"recordTerminalMember\"];\n readonly attach: RunWriteSession[\"attach\"];\n readonly record: RunWriteSession[\"record\"];\n readonly records: RunWriteSession[\"records\"];\n readonly seal: RunWriteSession[\"seal\"];\n}\nexport type RecordFormatInspection = {\n readonly state: \"already-current\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly state: \"migration-required\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly state: \"unsupported-format\";\n readonly format: string;\n};\nexport interface RecordAttachmentMigrationTarget {\n readonly family: string;\n readonly owner: \"attempt\" | \"run\";\n readonly runId: RunId;\n readonly attemptId?: AttemptId;\n readonly fromRevision: number;\n readonly toRevision: number;\n readonly retention: {\n readonly retainedFacts: readonly string[];\n readonly droppedFacts: readonly string[];\n readonly rerunRecommendation: string | null;\n };\n}\nexport type RecordMigrationPlan = {\n readonly state: \"already-current\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly state: \"migration-required\";\n readonly format: \"niceeval.record.attachments\";\n readonly sourceFormat: \"niceeval.record.attachments\" | \"niceeval.record.source-receipts\";\n readonly attachments: readonly RecordAttachmentMigrationTarget[];\n readonly pendingSeals: readonly RunId[];\n readonly resumedSteps: number;\n} | {\n readonly state: \"unsupported-format\";\n readonly format: string;\n};\nexport type RecordMigrationReceipt = {\n readonly state: \"already-current\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly state: \"migrated\";\n readonly format: \"niceeval.record.attachments\";\n readonly attachments: readonly RecordAttachmentMigrationTarget[];\n readonly committed: number;\n readonly skipped: number;\n readonly failed: number;\n readonly rebuiltSeals: readonly RunId[];\n};\n/** Closed, presentation-neutral plan for explicit incomplete-Run cleanup. */\nexport type RecordCleanOperationPlan = {\n readonly _tag: \"RecordCleanAlreadyClean\";\n} | {\n readonly _tag: \"RecordCleanConfirmationRequired\";\n readonly runIds: readonly RunId[];\n};\nexport interface RecordCleanOperationReceipt {\n readonly _tag: \"RecordCleanApplied\";\n readonly deleted: readonly RunId[];\n readonly skipped: readonly RunId[];\n}\n/**\n * A migration plan is safe to carry outside the maintenance Scope. The ready\n * branch remains nominally backed by the exact source-byte plan held by this\n * Host process; callers cannot manufacture an applicable plan from JSON.\n */\nexport type RecordMigrateOperationPlan = {\n readonly _tag: \"RecordMigrationAlreadyCurrent\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly _tag: \"RecordMigrationUnsupported\";\n readonly format: string;\n} | RecordMigrateReadyPlan;\nexport interface RecordMigrateReadyPlan {\n readonly _tag: \"RecordMigrationReady\";\n readonly format: \"niceeval.record.attachments\";\n readonly sourceFormat: \"niceeval.record.attachments\" | \"niceeval.record.source-receipts\";\n readonly attachments: readonly RecordAttachmentMigrationTarget[];\n readonly pendingSeals: readonly RunId[];\n readonly resumedSteps: number;\n}\nexport type RecordMigrateOperationReceipt = {\n readonly _tag: \"RecordMigrationAlreadyCurrent\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly _tag: \"RecordMigrationApplied\";\n readonly format: \"niceeval.record.attachments\";\n readonly attachments: readonly RecordAttachmentMigrationTarget[];\n readonly committed: number;\n readonly skipped: number;\n readonly failed: number;\n readonly rebuiltSeals: readonly RunId[];\n};\n/** Exhaustive failure vocabulary consumed by Record-owned CLI presentation. */\nexport type RecordMaintenanceOperationFailure = {\n readonly _tag: \"RecordMaintenanceBusy\";\n readonly code: \"record-maintenance-busy\";\n} | {\n readonly _tag: \"RecordMigrationPlanStale\";\n readonly code: \"record-migration-plan-stale\";\n} | {\n readonly _tag: \"RecordMigrationInvalid\";\n readonly code: \"record-migration-invalid\";\n readonly family: string;\n} | {\n readonly _tag: \"RecordFormatUnsupported\";\n readonly code: \"record-format-unsupported\";\n} | {\n readonly _tag: \"RecordMigrationRequired\";\n readonly code: \"record-migration-required\";\n} | {\n readonly _tag: \"RecordMaintenanceOperationFailed\";\n readonly code: string;\n};\nexport interface RecordMaintenanceSession {\n readonly inspect: () => Effect.Effect<RecordFormatInspection, RecordMaintenanceError>;\n readonly planMigrate: () => Effect.Effect<RecordMigrationPlan, RecordMaintenanceError>;\n readonly applyMigrate: (plan: RecordMigrationPlan) => Effect.Effect<RecordMigrationReceipt, RecordMaintenanceError>;\n}\nexport interface RecordHostSDK {\n readonly openRead: RecordHostSDK[\"current\"][\"openRead\"];\n readonly createRun: (request: CreateRunRequest | {\n readonly root: RecordRoot;\n readonly core: Omit<CreateRunRequest, \"root\">;\n }) => ReturnType<RecordHostSDK[\"current\"][\"createRun\"]>;\n readonly createReferenceRun: (request: CreateReferenceRunRequest | {\n readonly root: RecordRoot;\n readonly core: Omit<CreateReferenceRunRequest, \"root\">;\n }) => ReturnType<RecordHostSDK[\"current\"][\"createReferenceRun\"]>;\n readonly current: {\n readonly openRead: (input: {\n readonly root: RecordRoot;\n }) => Effect.Effect<RecordReadSession, RecordReaderOpenError, import(\"effect\").Scope.Scope | ProjectStateDatabase>;\n readonly createRun: (request: CreateRunRequest) => Effect.Effect<RunWriteSession, RecordReaderOpenError | RecordWriteError, import(\"effect\").Scope.Scope | import(\"../platform/services.ts\").RecordEntropy | import(\"../../coordination/record-leases.ts\").RecordCoordination | ProjectStateDatabase>;\n readonly createReferenceRun: (request: CreateReferenceRunRequest) => Effect.Effect<ReferenceRunWriteSession, RecordReaderOpenError | RecordWriteError, import(\"effect\").Scope.Scope | import(\"../platform/services.ts\").RecordEntropy | import(\"../../coordination/record-leases.ts\").RecordCoordination | ProjectStateDatabase>;\n };\n readonly maintenance: {\n readonly planClean: (input: {\n readonly root: RecordRoot;\n }) => Effect.Effect<RecordCleanOperationPlan, RecordMaintenanceOperationFailure, import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n readonly applyClean: (input: {\n readonly root: RecordRoot;\n readonly plan: Extract<RecordCleanOperationPlan, {\n readonly _tag: \"RecordCleanConfirmationRequired\";\n }>;\n }) => Effect.Effect<RecordCleanOperationReceipt, RecordMaintenanceOperationFailure, import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n readonly planMigrate: (input: {\n readonly root: RecordRoot;\n }) => Effect.Effect<RecordMigrateOperationPlan, RecordMaintenanceOperationFailure, import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n readonly applyMigrate: (input: {\n readonly root: RecordRoot;\n readonly plan: RecordMigrateReadyPlan;\n }) => Effect.Effect<RecordMigrateOperationReceipt, RecordMaintenanceOperationFailure, import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n readonly open: (input: {\n readonly root: RecordRoot;\n }) => Effect.Effect<RecordMaintenanceSession, RecordMaintenanceOpenError, import(\"effect\").Scope.Scope | import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":";;;AAgBa,QAAA,mBAAmB,GAAkB,MAAM,CAAC,iCAAiC,CAAC,CAAC;AAC/E,QAAA,uBAAuB,GAAkB,MAAM,CAAC,qCAAqC,CAAC,CAAC;AACvF,QAAA,qBAAqB,GAAkB,MAAM,CAAC,mCAAmC,CAAC,CAAC;AACnF,QAAA,oBAAoB,GAAkB,MAAM,CAAC,kCAAkC,CAAC,CAAC;AACjF,QAAA,wBAAwB,GAAkB,MAAM,CAAC,sCAAsC,CAAC,CAAC","sourcesContent":["import type { Effect, Schema, Stream } from \"effect\";\nimport type { ProjectStateDatabase } from \"../sqlite/project-state-database.ts\";\nimport type { RecordAttachmentCatalog, RecordAttachmentDefinition, } from \"../attachment/index.ts\";\nimport type { RecordContentHandle, RecordTextContentHandle, } from \"../attachment/content.ts\";\nimport type { AttachedContentError, AttachedContentRequirements, RecordAttachmentSessionBuilder, } from \"../writer/current-attachment.ts\";\nimport type { AttemptDocument, MemberDocument, RecordAttachmentOwner, RecordSlotIdentity, RunDocument, } from \"../model/core.ts\";\nimport type { RunContext } from \"../model/run-context.ts\";\nimport type { AttemptId, ExperimentId, RunId, SlotId, UtcMillis, } from \"../model/identifiers.ts\";\nimport type { RecordRoot } from \"../platform/root.ts\";\nimport type { RunAbsenceReason } from \"../../run/protocol.ts\";\nimport type { RunResourcePage } from \"../../run/storage/types.ts\";\nimport type { RecordAttachmentRead as ModelRecordAttachmentRead, RecordCoreRead, RecordWarning, } from \"../model/read-state.ts\";\nimport type { RecordMaintenanceError, RecordMaintenanceOpenError, RecordCompletenessError, RecordReaderOpenError, RecordReaderReadError, } from \"../reader/errors.ts\";\nimport type { RecordWriteError } from \"../writer/types.ts\";\nimport type { RecordFileSystemError } from \"../platform/errors.ts\";\nimport type { AnyRecordDefinition, AttemptRecordAppendCommand, AttemptRecordAppendReceipt, AttemptRecordCollectionLimitation, AttemptRecordCollectionDefinition, RecordDefinitionValue, RecordWriteCommand, } from \"../authoring.ts\";\nexport const selectedRunRefBrand: unique symbol = Symbol(\"@niceeval/record/SelectedRunRef\");\nexport const selectedAttemptRefBrand: unique symbol = Symbol(\"@niceeval/record/SelectedAttemptRef\");\nexport const selectedOwnerRefBrand: unique symbol = Symbol(\"@niceeval/record/SelectedOwnerRef\");\nexport const runWriteSessionBrand: unique symbol = Symbol(\"@niceeval/record/RunWriteSession\");\nexport const attemptWriteSessionBrand: unique symbol = Symbol(\"@niceeval/record/AttemptWriteSession\");\ntype AnyDefinition<Owner extends RecordAttachmentOwner = RecordAttachmentOwner> = RecordAttachmentDefinition<Owner, string, Schema.Top>;\ntype DefinitionValue<Definition extends AnyDefinition> = Schema.Schema.Type<Definition[\"schema\"]>;\n/** Nominal ref issued only by one live RecordReadSession. */\nexport interface SelectedRunRef {\n readonly runId: RunId;\n readonly [selectedRunRefBrand]: () => void;\n}\n/** Nominal exact reference to one immutable origin Attempt. */\nexport interface SelectedAttemptRef {\n readonly originRunId: RunId;\n readonly attemptId: AttemptId;\n /** Complete durable identity required before this Attempt can be referenced. */\n readonly publicationIdentity?: {\n readonly originRunId: string;\n readonly attemptId: string;\n readonly revision: number;\n };\n readonly [selectedAttemptRefBrand]: () => void;\n}\n/** Owner handle for a later catalog-authorized Attachment read. */\nexport interface SelectedOwnerRef<out Owner extends \"run\" | \"attempt\" = \"run\" | \"attempt\"> {\n readonly [selectedOwnerRefBrand]: () => void;\n /** Nominal type witness only; the actual owner identity stays Host-private. */\n readonly __owner?: () => Owner;\n}\n/**\n * The Host exposes current Attachment states without importing maintenance.\n * A reachable older revision is migration-required. Any other well-formed,\n * non-current revision remains unsupported data; malformed envelopes and\n * closures are invalid, never a reader-wide failure.\n */\nexport interface RecordAttachmentContentReader {\n /** Exact persisted byte length without loading Content bytes. */\n readonly byteLength: (handle: RecordContentHandle) => Effect.Effect<number, RecordReaderReadError>;\n readonly bytes: (handle: RecordContentHandle) => Effect.Effect<Uint8Array, RecordReaderReadError>;\n readonly text: (handle: RecordTextContentHandle) => Effect.Effect<string, RecordReaderReadError>;\n readonly stream: (handle: RecordContentHandle) => Stream.Stream<Uint8Array, RecordReaderReadError>;\n}\nexport type RecordAttachmentRead<Payload> = Exclude<ModelRecordAttachmentRead<Payload>, {\n readonly state: \"available\";\n}> | {\n readonly state: \"available\";\n /** Direct business fields from the current owner value definition. */\n readonly value: Payload;\n /** Scope-owned logical content consumption; it exposes no path or pointer. */\n readonly content: RecordAttachmentContentReader;\n};\ntype AttemptRecordCollectionRead<Payload> = Exclude<RecordAttachmentRead<Payload>, {\n readonly state: \"available\";\n}> | {\n readonly state: \"available\";\n readonly value: Payload;\n};\nexport type RecordSelectionProblem = {\n readonly code: \"incomplete-run\";\n readonly runId: RunId;\n} | {\n readonly code: \"record-core-invalid\";\n readonly runId: RunId;\n} | {\n readonly code: \"selection-run-missing\";\n readonly runId: RunId;\n};\nexport interface RecordSelectionRequest {\n /** Omitted means every terminal Run eligible for reuse during this scan. */\n readonly runIds?: readonly RunId[];\n /** Explicit locator resolution may include immutable publications from an active origin Run. */\n readonly includePublishedActive?: boolean;\n}\n/**\n * Closed Run facts verified by scanSelection. They retain the denominator\n * frame if a later member read becomes unavailable; they are not a durable\n * schema and contain no owner capability.\n */\nexport interface SelectedRunFacts {\n readonly run: SelectedRunRef;\n readonly experimentId: ExperimentId;\n readonly startedAt: UtcMillis;\n readonly completedAt: UtcMillis;\n readonly expectedSlots: readonly RecordSlotIdentity[];\n}\n/** A closed candidate set with only selected minimal Core; never Attachment payloads. */\nexport interface RecordSelection {\n readonly runRefs: readonly SelectedRunRef[];\n readonly runFacts: readonly SelectedRunFacts[];\n readonly expectedSlots: readonly {\n readonly run: SelectedRunRef;\n /** Closed at scan time from the selected Run, not stored in RecordSlotIdentity. */\n readonly experimentId: ExperimentId;\n readonly slot: RecordSlotIdentity;\n }[];\n readonly problems: readonly RecordSelectionProblem[];\n readonly warnings: readonly RecordWarning[];\n}\nexport interface ReadableRun {\n readonly createdRevision?: number;\n readonly ref: SelectedRunRef;\n readonly owner: SelectedOwnerRef<\"run\">;\n readonly document: RunDocument;\n readonly members: readonly {\n readonly document: MemberDocument;\n readonly bindingRevision?: number;\n readonly attempt: SelectedAttemptRef | null;\n }[];\n}\nexport interface ReadableAttempt {\n readonly ref: SelectedAttemptRef;\n readonly owner: SelectedOwnerRef<\"attempt\">;\n readonly document: AttemptDocument;\n /**\n * Verified while resolving the exact nominal Attempt reference. It is the\n * only origin Run Core projection Sample may use. In particular, a carried\n * or accepted member must retain this origin's execution facts rather than\n * substituting the selected target Run.\n */\n readonly origin: {\n readonly owner: SelectedOwnerRef<\"run\">;\n readonly runId: RunId;\n readonly experimentId: ExperimentId;\n readonly startedAt: UtcMillis;\n readonly context: RunContext;\n };\n}\nexport interface RecordReadSession {\n /** Lifecycle resources at this reader's cutoff, including zero-publication Runs. */\n readonly listRunResources: (input?: {\n readonly invocationId?: string;\n readonly afterRunId?: string;\n readonly pageSize?: number;\n }) => Effect.Effect<RunResourcePage, RecordReaderReadError>;\n readonly selectRuns: (request?: RecordSelectionRequest) => Effect.Effect<RecordSelection, RecordReaderReadError>;\n readonly readRun: (ref: SelectedRunRef) => Effect.Effect<RecordCoreRead<ReadableRun>, RecordReaderReadError>;\n readonly readAttempt: (ref: SelectedAttemptRef) => Effect.Effect<RecordCoreRead<ReadableAttempt>, RecordReaderReadError>;\n readonly read: {\n <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>>(owner: SelectedOwnerRef<\"attempt\">, definition: Definition): Effect.Effect<AttemptRecordCollectionRead<Schema.Schema.Type<Definition[\"schema\"]>>, RecordReaderReadError>;\n <Owner extends \"run\" | \"attempt\", Definition extends AnyRecordDefinition<Owner>>(owner: SelectedOwnerRef<Owner>, definition: Definition): Effect.Effect<RecordAttachmentRead<RecordDefinitionValue<Definition>>, RecordReaderReadError>;\n <Owner extends \"run\" | \"attempt\", Definition extends AnyDefinition<Owner>>(owner: SelectedOwnerRef<Owner>, definition: Definition): Effect.Effect<RecordAttachmentRead<DefinitionValue<Definition>>, RecordReaderReadError>;\n };\n readonly openCollection: <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>>(owner: SelectedOwnerRef<\"attempt\">, definition: Definition) => Effect.Effect<Exclude<AttemptRecordCollectionRead<Schema.Schema.Type<Definition[\"schema\"]>>, {\n readonly state: \"available\";\n }> | {\n readonly state: \"available\";\n readonly collection: Schema.Schema.Type<Definition[\"schema\"]>[\"collection\"];\n readonly logicalIdentity: string;\n readonly logicalSealIdentity: string;\n readonly count: number;\n readonly digest: string;\n readonly items: Stream.Stream<Schema.Schema.Type<Definition[\"item\"]>, RecordReaderReadError>;\n }, RecordReaderReadError>;\n readonly requireComplete: (selection: RecordSelection) => Effect.Effect<RecordCompleteView, RecordCompletenessError>;\n}\n/** Complete only for this session's frozen selection and immutable catalog. */\nexport interface RecordCompleteView {\n readonly selection: RecordSelection;\n readonly attachments: RecordAttachmentCatalog;\n}\nexport interface CreateRunRequest {\n readonly root: RecordRoot;\n readonly experimentId: ExperimentId;\n /** Required historical interpretation facts, written once into `run.json`. */\n readonly context: RunContext;\n readonly startedAt: UtcMillis;\n readonly expectedSlots: readonly RecordSlotIdentity[];\n /** Host-private exact process identity used for crash recovery fencing. */\n readonly writerGeneration?: string;\n}\nexport interface CreateReferenceRunRequest extends CreateRunRequest {\n}\nexport interface RunCompletion {\n readonly completedAt: UtcMillis;\n}\nexport interface RecordSealReceipt {\n readonly runId: RunId;\n readonly state: \"sealed\";\n}\nexport interface AttemptWriteSession {\n readonly attemptId: AttemptId;\n readonly slotId: SlotId;\n readonly [attemptWriteSessionBrand]: () => void;\n readonly complete: (outcome: AttemptDocument[\"outcome\"]) => Effect.Effect<void, RecordWriteError>;\n readonly attach: OwnerAttachmentWriter<\"attempt\">;\n readonly record: AttemptRecordWriter;\n readonly records: AttemptRecordsWriter;\n}\nexport interface OwnerRecordsWriter<Owner extends \"run\" | \"attempt\"> {\n readonly write: {\n <Definition extends AnyRecordDefinition<Owner>>(definition: Definition, value: RecordDefinitionValue<Definition> | ((build: RecordAttachmentSessionBuilder) => RecordDefinitionValue<Definition>)): Effect.Effect<void, RecordWriteError | AttachedContentError<RecordDefinitionValue<Definition>>, AttachedContentRequirements<RecordDefinitionValue<Definition>>>;\n <Definition extends AnyDefinition<Owner>, Value extends DefinitionValue<Definition>>(definition: Definition, value: Value | ((build: RecordAttachmentSessionBuilder) => Value)): Effect.Effect<void, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>>;\n };\n}\nexport interface AttemptRecordsWriter extends OwnerRecordsWriter<\"attempt\"> {\n readonly append: <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>>(definition: Definition, item: Schema.Schema.Type<Definition[\"item\"]>) => Effect.Effect<AttemptRecordAppendReceipt, RecordWriteError>;\n readonly appendAll: <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>, Error, Requirements>(definition: Definition, items: Stream.Stream<Schema.Schema.Type<Definition[\"item\"]>, Error, Requirements>) => Effect.Effect<void, RecordWriteError | Error, Requirements>;\n readonly close: <Definition extends AttemptRecordCollectionDefinition<string, Schema.Top>>(definition: Definition, completion: {\n readonly state: \"complete\";\n } | {\n readonly state: \"partial\";\n readonly limitations: readonly [\n AttemptRecordCollectionLimitation,\n ...AttemptRecordCollectionLimitation[]\n ];\n }) => Effect.Effect<void, RecordWriteError>;\n}\nexport interface OwnerRecordWriter<Owner extends \"run\" | \"attempt\"> {\n readonly write: <Value, Error, Requirements>(command: RecordWriteCommand<Owner, Value, Error, Requirements>) => Effect.Effect<void, RecordWriteError | Error, Requirements>;\n}\nexport interface AttemptRecordWriter extends OwnerRecordWriter<\"attempt\"> {\n readonly start: (definition: AttemptRecordCollectionDefinition<string, Schema.Top>) => Effect.Effect<void, RecordWriteError>;\n readonly append: <Item>(command: AttemptRecordAppendCommand<Item>) => Effect.Effect<AttemptRecordAppendReceipt, RecordWriteError>;\n}\nexport interface OwnerAttachmentWriter<Owner extends \"run\" | \"attempt\"> {\n <Definition extends AnyDefinition<Owner>, Value extends DefinitionValue<Definition>>(definition: Definition, value: Value | ((build: RecordAttachmentSessionBuilder) => Value)): Effect.Effect<void, RecordWriteError | AttachedContentError<Value>, AttachedContentRequirements<Value>>;\n}\n/** One session owns exactly one freshly exclusive RunId directory. */\nexport interface RunWriteSession {\n readonly runId: RunId;\n readonly [runWriteSessionBrand]: () => void;\n readonly createAttempt: (input: {\n readonly slotId: SlotId;\n }) => Effect.Effect<AttemptWriteSession, RecordWriteError>;\n readonly referenceAttempt: (input: {\n readonly slotId: SlotId;\n readonly action: \"carried\" | \"accepted\";\n readonly attempt: SelectedAttemptRef;\n }) => Effect.Effect<void, RecordWriteError>;\n /**\n * Explicit adoption / rename: occupy one current target Slot with an already\n * selected origin Attempt. The target Slot identity may differ from the\n * origin Attempt. This is not a generic Attachment writer.\n */\n readonly recordAcceptedMembership: (input: {\n readonly slotId: SlotId;\n readonly attempt: SelectedAttemptRef;\n }) => Effect.Effect<void, RecordWriteError>;\n readonly recordTerminalMember: (input: {\n readonly slotId: SlotId;\n readonly action: \"not-dispatched\" | \"interrupted\";\n readonly absenceReason: RunAbsenceReason;\n }) => Effect.Effect<void, RecordWriteError>;\n readonly attach: OwnerAttachmentWriter<\"run\">;\n readonly record: OwnerRecordWriter<\"run\">;\n readonly records: OwnerRecordsWriter<\"run\">;\n readonly seal: (completion: RunCompletion) => Effect.Effect<RecordSealReceipt, RecordWriteError>;\n}\n/** A Run created solely from already-selected, sealed Attempts. */\nexport interface ReferenceRunWriteSession {\n readonly runId: RunId;\n readonly [runWriteSessionBrand]: () => void;\n readonly referenceAttempt: RunWriteSession[\"referenceAttempt\"];\n readonly recordAcceptedMembership: RunWriteSession[\"recordAcceptedMembership\"];\n readonly recordTerminalMember: RunWriteSession[\"recordTerminalMember\"];\n readonly attach: RunWriteSession[\"attach\"];\n readonly record: RunWriteSession[\"record\"];\n readonly records: RunWriteSession[\"records\"];\n readonly seal: RunWriteSession[\"seal\"];\n}\nexport type RecordFormatInspection = {\n readonly state: \"already-current\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly state: \"migration-required\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly state: \"unsupported-format\";\n readonly format: string;\n};\nexport interface RecordAttachmentMigrationTarget {\n readonly family: string;\n readonly owner: \"attempt\" | \"run\";\n readonly runId: RunId;\n readonly attemptId?: AttemptId;\n readonly fromRevision: number;\n readonly toRevision: number;\n readonly retention: {\n readonly retainedFacts: readonly string[];\n readonly droppedFacts: readonly string[];\n readonly rerunRecommendation: string | null;\n };\n}\nexport type RecordMigrationPlan = {\n readonly state: \"already-current\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly state: \"migration-required\";\n readonly format: \"niceeval.record.attachments\";\n readonly sourceFormat: \"niceeval.record.attachments\" | \"niceeval.record.source-receipts\";\n readonly attachments: readonly RecordAttachmentMigrationTarget[];\n readonly pendingSeals: readonly RunId[];\n readonly resumedSteps: number;\n} | {\n readonly state: \"unsupported-format\";\n readonly format: string;\n};\nexport type RecordMigrationReceipt = {\n readonly state: \"already-current\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly state: \"migrated\";\n readonly format: \"niceeval.record.attachments\";\n readonly attachments: readonly RecordAttachmentMigrationTarget[];\n readonly committed: number;\n readonly skipped: number;\n readonly failed: number;\n readonly rebuiltSeals: readonly RunId[];\n};\n/** Closed, presentation-neutral plan for explicit incomplete-Run cleanup. */\nexport type RecordCleanOperationPlan = {\n readonly _tag: \"RecordCleanAlreadyClean\";\n} | {\n readonly _tag: \"RecordCleanConfirmationRequired\";\n readonly runIds: readonly RunId[];\n};\nexport interface RecordCleanOperationReceipt {\n readonly _tag: \"RecordCleanApplied\";\n readonly deleted: readonly RunId[];\n readonly skipped: readonly RunId[];\n}\n/**\n * A migration plan is safe to carry outside the maintenance Scope. The ready\n * branch remains nominally backed by the exact source-byte plan held by this\n * Host process; callers cannot manufacture an applicable plan from JSON.\n */\nexport type RecordMigrateOperationPlan = {\n readonly _tag: \"RecordMigrationAlreadyCurrent\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly _tag: \"RecordMigrationUnsupported\";\n readonly format: string;\n} | RecordMigrateReadyPlan;\nexport interface RecordMigrateReadyPlan {\n readonly _tag: \"RecordMigrationReady\";\n readonly format: \"niceeval.record.attachments\";\n readonly sourceFormat: \"niceeval.record.attachments\" | \"niceeval.record.source-receipts\";\n readonly attachments: readonly RecordAttachmentMigrationTarget[];\n readonly pendingSeals: readonly RunId[];\n readonly resumedSteps: number;\n}\nexport type RecordMigrateOperationReceipt = {\n readonly _tag: \"RecordMigrationAlreadyCurrent\";\n readonly format: \"niceeval.record.attachments\";\n} | {\n readonly _tag: \"RecordMigrationApplied\";\n readonly format: \"niceeval.record.attachments\";\n readonly attachments: readonly RecordAttachmentMigrationTarget[];\n readonly committed: number;\n readonly skipped: number;\n readonly failed: number;\n readonly rebuiltSeals: readonly RunId[];\n};\n/** Exhaustive failure vocabulary consumed by Record-owned CLI presentation. */\nexport type RecordMaintenanceOperationFailure = {\n readonly _tag: \"RecordMaintenanceBusy\";\n readonly code: \"record-maintenance-busy\";\n} | {\n readonly _tag: \"RecordMigrationPlanStale\";\n readonly code: \"record-migration-plan-stale\";\n} | {\n readonly _tag: \"RecordMigrationInvalid\";\n readonly code: \"record-migration-invalid\";\n readonly family: string;\n} | {\n readonly _tag: \"RecordFormatUnsupported\";\n readonly code: \"record-format-unsupported\";\n} | {\n readonly _tag: \"RecordMigrationRequired\";\n readonly code: \"record-migration-required\";\n} | {\n readonly _tag: \"RecordMaintenanceOperationFailed\";\n readonly code: string;\n};\nexport interface RecordMaintenanceSession {\n readonly inspect: () => Effect.Effect<RecordFormatInspection, RecordMaintenanceError>;\n readonly planMigrate: () => Effect.Effect<RecordMigrationPlan, RecordMaintenanceError>;\n readonly applyMigrate: (plan: RecordMigrationPlan) => Effect.Effect<RecordMigrationReceipt, RecordMaintenanceError>;\n}\nexport interface RecordHostSDK {\n readonly openRead: RecordHostSDK[\"current\"][\"openRead\"];\n readonly createRun: (request: CreateRunRequest | {\n readonly root: RecordRoot;\n readonly core: Omit<CreateRunRequest, \"root\">;\n }) => ReturnType<RecordHostSDK[\"current\"][\"createRun\"]>;\n readonly createReferenceRun: (request: CreateReferenceRunRequest | {\n readonly root: RecordRoot;\n readonly core: Omit<CreateReferenceRunRequest, \"root\">;\n }) => ReturnType<RecordHostSDK[\"current\"][\"createReferenceRun\"]>;\n readonly current: {\n readonly openRead: (input: {\n readonly root: RecordRoot;\n }) => Effect.Effect<RecordReadSession, RecordReaderOpenError, import(\"effect\").Scope.Scope | ProjectStateDatabase>;\n readonly createRun: (request: CreateRunRequest) => Effect.Effect<RunWriteSession, RecordReaderOpenError | RecordWriteError, import(\"effect\").Scope.Scope | import(\"../platform/services.ts\").RecordEntropy | import(\"../../coordination/record-leases.ts\").RecordCoordination | ProjectStateDatabase>;\n readonly createReferenceRun: (request: CreateReferenceRunRequest) => Effect.Effect<ReferenceRunWriteSession, RecordReaderOpenError | RecordWriteError, import(\"effect\").Scope.Scope | import(\"../platform/services.ts\").RecordEntropy | import(\"../../coordination/record-leases.ts\").RecordCoordination | ProjectStateDatabase>;\n };\n readonly maintenance: {\n readonly planClean: (input: {\n readonly root: RecordRoot;\n }) => Effect.Effect<RecordCleanOperationPlan, RecordMaintenanceOperationFailure, import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n readonly applyClean: (input: {\n readonly root: RecordRoot;\n readonly plan: Extract<RecordCleanOperationPlan, {\n readonly _tag: \"RecordCleanConfirmationRequired\";\n }>;\n }) => Effect.Effect<RecordCleanOperationReceipt, RecordMaintenanceOperationFailure, import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n readonly planMigrate: (input: {\n readonly root: RecordRoot;\n }) => Effect.Effect<RecordMigrateOperationPlan, RecordMaintenanceOperationFailure, import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n readonly applyMigrate: (input: {\n readonly root: RecordRoot;\n readonly plan: RecordMigrateReadyPlan;\n }) => Effect.Effect<RecordMigrateOperationReceipt, RecordMaintenanceOperationFailure, import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n readonly open: (input: {\n readonly root: RecordRoot;\n }) => Effect.Effect<RecordMaintenanceSession, RecordMaintenanceOpenError, import(\"effect\").Scope.Scope | import(\"../../coordination/record-leases.ts\").RecordCoordination>;\n };\n}\n"]}
|
|
@@ -8,6 +8,7 @@ import type { RunContext } from "../model/run-context.cjs";
|
|
|
8
8
|
import type { AttemptId, ExperimentId, RunId, SlotId, UtcMillis } from "../model/identifiers.cjs";
|
|
9
9
|
import type { RecordRoot } from "../platform/root.cjs";
|
|
10
10
|
import type { RunAbsenceReason } from "../../run/protocol.cjs";
|
|
11
|
+
import type { RunResourcePage } from "../../run/storage/types.cjs";
|
|
11
12
|
import type { RecordAttachmentRead as ModelRecordAttachmentRead, RecordCoreRead, RecordWarning } from "../model/read-state.cjs";
|
|
12
13
|
import type { RecordMaintenanceError, RecordMaintenanceOpenError, RecordCompletenessError, RecordReaderOpenError, RecordReaderReadError } from "../reader/errors.cjs";
|
|
13
14
|
import type { RecordWriteError } from "../writer/types.cjs";
|
|
@@ -141,6 +142,12 @@ export interface ReadableAttempt {
|
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
export interface RecordReadSession {
|
|
145
|
+
/** Lifecycle resources at this reader's cutoff, including zero-publication Runs. */
|
|
146
|
+
readonly listRunResources: (input?: {
|
|
147
|
+
readonly invocationId?: string;
|
|
148
|
+
readonly afterRunId?: string;
|
|
149
|
+
readonly pageSize?: number;
|
|
150
|
+
}) => Effect.Effect<RunResourcePage, RecordReaderReadError>;
|
|
144
151
|
readonly selectRuns: (request?: RecordSelectionRequest) => Effect.Effect<RecordSelection, RecordReaderReadError>;
|
|
145
152
|
readonly readRun: (ref: SelectedRunRef) => Effect.Effect<RecordCoreRead<ReadableRun>, RecordReaderReadError>;
|
|
146
153
|
readonly readAttempt: (ref: SelectedAttemptRef) => Effect.Effect<RecordCoreRead<ReadableAttempt>, RecordReaderReadError>;
|
|
@@ -8,6 +8,7 @@ import type { RunContext } from "../model/run-context.mjs";
|
|
|
8
8
|
import type { AttemptId, ExperimentId, RunId, SlotId, UtcMillis } from "../model/identifiers.mjs";
|
|
9
9
|
import type { RecordRoot } from "../platform/root.mjs";
|
|
10
10
|
import type { RunAbsenceReason } from "../../run/protocol.mjs";
|
|
11
|
+
import type { RunResourcePage } from "../../run/storage/types.mjs";
|
|
11
12
|
import type { RecordAttachmentRead as ModelRecordAttachmentRead, RecordCoreRead, RecordWarning } from "../model/read-state.mjs";
|
|
12
13
|
import type { RecordMaintenanceError, RecordMaintenanceOpenError, RecordCompletenessError, RecordReaderOpenError, RecordReaderReadError } from "../reader/errors.mjs";
|
|
13
14
|
import type { RecordWriteError } from "../writer/types.mjs";
|
|
@@ -141,6 +142,12 @@ export interface ReadableAttempt {
|
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
export interface RecordReadSession {
|
|
145
|
+
/** Lifecycle resources at this reader's cutoff, including zero-publication Runs. */
|
|
146
|
+
readonly listRunResources: (input?: {
|
|
147
|
+
readonly invocationId?: string;
|
|
148
|
+
readonly afterRunId?: string;
|
|
149
|
+
readonly pageSize?: number;
|
|
150
|
+
}) => Effect.Effect<RunResourcePage, RecordReaderReadError>;
|
|
144
151
|
readonly selectRuns: (request?: RecordSelectionRequest) => Effect.Effect<RecordSelection, RecordReaderReadError>;
|
|
145
152
|
readonly readRun: (ref: SelectedRunRef) => Effect.Effect<RecordCoreRead<ReadableRun>, RecordReaderReadError>;
|
|
146
153
|
readonly readAttempt: (ref: SelectedAttemptRef) => Effect.Effect<RecordCoreRead<ReadableAttempt>, RecordReaderReadError>;
|
|
@@ -8,6 +8,7 @@ import type { RunContext } from "../model/run-context.js";
|
|
|
8
8
|
import type { AttemptId, ExperimentId, RunId, SlotId, UtcMillis } from "../model/identifiers.js";
|
|
9
9
|
import type { RecordRoot } from "../platform/root.js";
|
|
10
10
|
import type { RunAbsenceReason } from "../../run/protocol.js";
|
|
11
|
+
import type { RunResourcePage } from "../../run/storage/types.js";
|
|
11
12
|
import type { RecordAttachmentRead as ModelRecordAttachmentRead, RecordCoreRead, RecordWarning } from "../model/read-state.js";
|
|
12
13
|
import type { RecordMaintenanceError, RecordMaintenanceOpenError, RecordCompletenessError, RecordReaderOpenError, RecordReaderReadError } from "../reader/errors.js";
|
|
13
14
|
import type { RecordWriteError } from "../writer/types.js";
|
|
@@ -141,6 +142,12 @@ export interface ReadableAttempt {
|
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
export interface RecordReadSession {
|
|
145
|
+
/** Lifecycle resources at this reader's cutoff, including zero-publication Runs. */
|
|
146
|
+
readonly listRunResources: (input?: {
|
|
147
|
+
readonly invocationId?: string;
|
|
148
|
+
readonly afterRunId?: string;
|
|
149
|
+
readonly pageSize?: number;
|
|
150
|
+
}) => Effect.Effect<RunResourcePage, RecordReaderReadError>;
|
|
144
151
|
readonly selectRuns: (request?: RecordSelectionRequest) => Effect.Effect<RecordSelection, RecordReaderReadError>;
|
|
145
152
|
readonly readRun: (ref: SelectedRunRef) => Effect.Effect<RecordCoreRead<ReadableRun>, RecordReaderReadError>;
|
|
146
153
|
readonly readAttempt: (ref: SelectedAttemptRef) => Effect.Effect<RecordCoreRead<ReadableAttempt>, RecordReaderReadError>;
|
|
@@ -4,6 +4,8 @@ exports.RunContextSchema = exports.AdapterIdentitySchema = exports.RunContextLim
|
|
|
4
4
|
exports.canonicalizeRunContext = canonicalizeRunContext;
|
|
5
5
|
exports.validateRunContext = validateRunContext;
|
|
6
6
|
exports.runContextCanonicalJson = runContextCanonicalJson;
|
|
7
|
+
const model_slots_ts_1 = require("../../model-slots.cjs");
|
|
8
|
+
const adapter_cleanup_ts_1 = require("../../shared/adapter-cleanup.cjs");
|
|
7
9
|
const effect_1 = require("effect");
|
|
8
10
|
const index_ts_1 = require("../definition/index.cjs");
|
|
9
11
|
const identifiers_ts_1 = require("../codec/identifiers.cjs");
|
|
@@ -36,8 +38,10 @@ exports.AdapterIdentitySchema = effect_1.Schema.Struct({
|
|
|
36
38
|
name: NonEmptyStringSchema,
|
|
37
39
|
contract: NonEmptyStringSchema,
|
|
38
40
|
behaviorRevision: effect_1.Schema.NullOr(NonEmptyStringSchema),
|
|
41
|
+
cleanupTimeoutMs: effect_1.Schema.optionalKey(adapter_cleanup_ts_1.AdapterCleanupTimeoutMsSchema),
|
|
39
42
|
});
|
|
40
43
|
const RunExecutionContextSchema = effect_1.Schema.Struct({
|
|
44
|
+
models: effect_1.Schema.optionalKey(model_slots_ts_1.ResolvedModelSlotsSchema),
|
|
41
45
|
adapter: exports.AdapterIdentitySchema,
|
|
42
46
|
model: effect_1.Schema.NullOr(effect_1.Schema.String),
|
|
43
47
|
reasoningEffort: effect_1.Schema.NullOr(effect_1.Schema.String),
|
|
@@ -47,7 +51,9 @@ const RunExecutionContextSchema = effect_1.Schema.Struct({
|
|
|
47
51
|
setup: effect_1.Schema.Literals(["absent", "opaque"]),
|
|
48
52
|
teardown: effect_1.Schema.Literals(["absent", "opaque"]),
|
|
49
53
|
})),
|
|
50
|
-
})
|
|
54
|
+
}).check(effect_1.Schema.makeFilter((value) => value.models === undefined ||
|
|
55
|
+
(value.model === (value.models.default?.model ?? null) &&
|
|
56
|
+
value.reasoningEffort === (value.models.default?.reasoningEffort ?? null))));
|
|
51
57
|
const RunLabelsSchema = effect_1.Schema.Record(effect_1.Schema.String, effect_1.Schema.String);
|
|
52
58
|
const RunContextCurrentSchema = effect_1.Schema.Struct({
|
|
53
59
|
experimentId: identifiers_ts_1.ExperimentIdSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-context.js","sourceRoot":"","sources":["run-context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"run-context.js","sourceRoot":"","sources":["run-context.ts"],"names":[],"mappings":";;;AA4GA,wDAKC;AACD,gDAGC;AACD,0DAMC;AA5HD,yDAAyF;AACzF,wEAAgF;AAChF,mCAAwC;AACxC,qDAAqJ;AAErJ,4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M,CAAC,OAAO,CAAC,CAAC;IACrD,IAAI,eAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,IAAA,kCAAuB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { ResolvedModelSlotsSchema, type ResolvedModelSlots } from \"../../model-slots.ts\";\nimport { AdapterCleanupTimeoutMsSchema } from \"../../shared/adapter-cleanup.ts\";\nimport { Result, Schema } from \"effect\";\nimport { canonicalRecordJsonText, defineRecordCore, type RecordJson, type RecordJsonObject, type RecordSchemaLimits, } from \"../definition/index.ts\";\nimport type { RecordSchemaFailure } from \"../definition/schema-codec.ts\";\nimport { ExperimentIdSchema } from \"../codec/identifiers.ts\";\nimport { nonEmptyRecordIssues, recordIssue, type NonEmptyRecordIssues, type RecordIssue, } from \"../errors/record-errors.ts\";\nimport type { ExperimentId } from \"./identifiers.ts\";\n/** The complete budget for one immutable, self-explaining Run context. */\nexport const RunContextLimits: RecordSchemaLimits = Object.freeze({\n maximumJsonBytes: 256 * 1024,\n maximumDepth: 8,\n maximumNodes: 4096,\n maximumObjectKeys: 64,\n maximumArrayItems: 256,\n maximumKeyUtf8Bytes: 256,\n maximumStringUtf8Bytes: 8 * 1024,\n});\nexport type RunContextJsonValue = RecordJson;\nexport type RunContextJsonObject = RecordJsonObject;\n/** Credential-free, presentation-neutral identity of the Adapter evaluated by a Run. */\nexport type AdapterIdentity = {\n readonly name: string;\n /** Descriptive contract name; pairing and capabilities use runtime construction evidence. */\n readonly contract: string;\n /** `null` means the author did not claim a stable behavior revision. */\n readonly behaviorRevision: string | null;\n /** Custom Adapter cleanup budget; absent when not applicable or not recorded. */\n readonly cleanupTimeoutMs?: number;\n};\nexport interface RunExecutionContext {\n readonly models?: ResolvedModelSlots;\n readonly adapter: AdapterIdentity;\n readonly model: string | null;\n readonly reasoningEffort: string | null;\n /** Secret-free author-declared JSON. Its meaning is deliberately not inferred. */\n readonly flags: RunContextJsonObject;\n /** Declared execution inputs; omission in historical data means unknown. */\n readonly experimentHooks?: {\n readonly version: 1;\n readonly setup: \"absent\" | \"opaque\";\n readonly teardown: \"absent\" | \"opaque\";\n };\n}\n/** Core history required to interpret the sealed Run without current configuration. */\nexport interface RunContext {\n readonly experimentId: ExperimentId;\n readonly execution: RunExecutionContext;\n readonly labels: Readonly<Record<string, string>>;\n}\n/**\n * `flags` is intentionally an open v1 JSON object. Keep its recursive exact\n * JSON shape in Schema rather than reducing it to an opaque runtime guard.\n */\nconst RunContextJsonValueSchema: Schema.Codec<RunContextJsonValue> = Schema.suspend(() => Schema.Union([\n Schema.Null,\n Schema.Boolean,\n Schema.Number,\n Schema.String,\n Schema.Array(RunContextJsonValueSchema),\n Schema.Record(Schema.String, RunContextJsonValueSchema),\n]));\nconst RunContextJsonObjectSchema: Schema.Codec<RunContextJsonObject> = Schema.Record(Schema.String, RunContextJsonValueSchema);\nconst NonEmptyStringSchema = Schema.String.pipe(Schema.check(Schema.isMinLength(1)));\nexport const AdapterIdentitySchema: Schema.Codec<AdapterIdentity> = Schema.Struct({\n name: NonEmptyStringSchema,\n contract: NonEmptyStringSchema,\n behaviorRevision: Schema.NullOr(NonEmptyStringSchema),\n cleanupTimeoutMs: Schema.optionalKey(AdapterCleanupTimeoutMsSchema),\n});\nconst RunExecutionContextSchema: Schema.Codec<RunExecutionContext> = Schema.Struct({\n models: Schema.optionalKey(ResolvedModelSlotsSchema),\n adapter: AdapterIdentitySchema,\n model: Schema.NullOr(Schema.String),\n reasoningEffort: Schema.NullOr(Schema.String),\n flags: RunContextJsonObjectSchema,\n experimentHooks: Schema.optionalKey(Schema.Struct({\n version: Schema.Literal(1),\n setup: Schema.Literals([\"absent\", \"opaque\"]),\n teardown: Schema.Literals([\"absent\", \"opaque\"]),\n })),\n}).check(Schema.makeFilter((value) => value.models === undefined ||\n (value.model === (value.models.default?.model ?? null) &&\n value.reasoningEffort === (value.models.default?.reasoningEffort ?? null))));\nconst RunLabelsSchema: Schema.Codec<Readonly<Record<string, string>>> = Schema.Record(Schema.String, Schema.String);\nconst RunContextCurrentSchema = Schema.Struct({\n experimentId: ExperimentIdSchema,\n execution: RunExecutionContextSchema,\n labels: RunLabelsSchema,\n});\n/** Run Context is Core, not an Attachment. */\nconst RunContextDefinition = defineRecordCore({\n schema: RunContextCurrentSchema,\n limits: RunContextLimits,\n});\nexport const RunContextSchema = RunContextDefinition.schema;\nfunction issuesFromFailure(failure: RecordSchemaFailure): NonEmptyRecordIssues {\n const issue: RecordIssue = failure.kind === \"canonical\"\n ? recordIssue(failure.failure.code === \"record-json-limit-exceeded\"\n ? \"record-run-context-size-exceeded\"\n : \"record-run-context-invalid\", failure.failure.path)\n : recordIssue(\"record-run-context-invalid\");\n const issues = nonEmptyRecordIssues([issue]);\n if (issues === undefined)\n throw new Error(\"Run context failure must contain one issue\");\n return issues;\n}\n/** Decode, canonicalize, validate exactly, and deep-freeze the current Context. */\nexport function canonicalizeRunContext(input: unknown): Result.Result<RunContext, NonEmptyRecordIssues> {\n const decoded = RunContextDefinition.decode(input);\n return Result.isFailure(decoded)\n ? Result.fail(issuesFromFailure(decoded.failure))\n : Result.succeed(decoded.success);\n}\nexport function validateRunContext(input: unknown): readonly RecordIssue[] {\n const decoded = canonicalizeRunContext(input);\n return Result.isFailure(decoded) ? decoded.failure : Object.freeze([]);\n}\nexport function runContextCanonicalJson(context: RunContext): string {\n const encoded = RunContextDefinition.encode(context);\n if (Result.isFailure(encoded)) {\n throw new Error(\"A RunContext value must be valid before serialization\");\n }\n return canonicalRecordJsonText(encoded.success);\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ResolvedModelSlots } from "../../model-slots.cjs";
|
|
1
2
|
import { Result, Schema } from "effect";
|
|
2
3
|
import { type RecordJson, type RecordJsonObject, type RecordSchemaLimits } from "../definition/index.cjs";
|
|
3
4
|
import { type NonEmptyRecordIssues, type RecordIssue } from "../errors/record-errors.cjs";
|
|
@@ -13,8 +14,11 @@ export type AdapterIdentity = {
|
|
|
13
14
|
readonly contract: string;
|
|
14
15
|
/** `null` means the author did not claim a stable behavior revision. */
|
|
15
16
|
readonly behaviorRevision: string | null;
|
|
17
|
+
/** Custom Adapter cleanup budget; absent when not applicable or not recorded. */
|
|
18
|
+
readonly cleanupTimeoutMs?: number;
|
|
16
19
|
};
|
|
17
20
|
export interface RunExecutionContext {
|
|
21
|
+
readonly models?: ResolvedModelSlots;
|
|
18
22
|
readonly adapter: AdapterIdentity;
|
|
19
23
|
readonly model: string | null;
|
|
20
24
|
readonly reasoningEffort: string | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ResolvedModelSlots } from "../../model-slots.mjs";
|
|
1
2
|
import { Result, Schema } from "effect";
|
|
2
3
|
import { type RecordJson, type RecordJsonObject, type RecordSchemaLimits } from "../definition/index.mjs";
|
|
3
4
|
import { type NonEmptyRecordIssues, type RecordIssue } from "../errors/record-errors.mjs";
|
|
@@ -13,8 +14,11 @@ export type AdapterIdentity = {
|
|
|
13
14
|
readonly contract: string;
|
|
14
15
|
/** `null` means the author did not claim a stable behavior revision. */
|
|
15
16
|
readonly behaviorRevision: string | null;
|
|
17
|
+
/** Custom Adapter cleanup budget; absent when not applicable or not recorded. */
|
|
18
|
+
readonly cleanupTimeoutMs?: number;
|
|
16
19
|
};
|
|
17
20
|
export interface RunExecutionContext {
|
|
21
|
+
readonly models?: ResolvedModelSlots;
|
|
18
22
|
readonly adapter: AdapterIdentity;
|
|
19
23
|
readonly model: string | null;
|
|
20
24
|
readonly reasoningEffort: string | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ResolvedModelSlots } from "../../model-slots.js";
|
|
1
2
|
import { Result, Schema } from "effect";
|
|
2
3
|
import { type RecordJson, type RecordJsonObject, type RecordSchemaLimits } from "../definition/index.js";
|
|
3
4
|
import { type NonEmptyRecordIssues, type RecordIssue } from "../errors/record-errors.js";
|
|
@@ -13,8 +14,11 @@ export type AdapterIdentity = {
|
|
|
13
14
|
readonly contract: string;
|
|
14
15
|
/** `null` means the author did not claim a stable behavior revision. */
|
|
15
16
|
readonly behaviorRevision: string | null;
|
|
17
|
+
/** Custom Adapter cleanup budget; absent when not applicable or not recorded. */
|
|
18
|
+
readonly cleanupTimeoutMs?: number;
|
|
16
19
|
};
|
|
17
20
|
export interface RunExecutionContext {
|
|
21
|
+
readonly models?: ResolvedModelSlots;
|
|
18
22
|
readonly adapter: AdapterIdentity;
|
|
19
23
|
readonly model: string | null;
|
|
20
24
|
readonly reasoningEffort: string | null;
|
|
@@ -2,7 +2,7 @@ import type { AttemptId, CanonicalRunRelativePath, RecordId, RunId, Sha256Digest
|
|
|
2
2
|
export declare const SEAL_MANIFEST_FORMAT: "niceeval.seal-manifest";
|
|
3
3
|
export declare const PUBLISH_RECOVERY_FORMAT: "niceeval.publish-recovery";
|
|
4
4
|
/** Compatibility alias derived from the official branded definition catalog. */
|
|
5
|
-
export declare const FIXED_RECORD_FAMILIES: readonly ["niceeval.adapter-usage", "niceeval.assertions", "niceeval.attempt-cost", "niceeval.agent-turns", "niceeval.turn-contexts", "niceeval.sandbox-commands", "niceeval.runner-activities", "niceeval.runner-diagnostics", "niceeval.file-changes", "niceeval.execution-traces", "niceeval.sources", "niceeval.artifacts"];
|
|
5
|
+
export declare const FIXED_RECORD_FAMILIES: readonly ["niceeval.adapter-usage", "niceeval.judge-usage", "niceeval.assertions", "niceeval.attempt-cost", "niceeval.agent-turns", "niceeval.turn-contexts", "niceeval.sandbox-commands", "niceeval.runner-activities", "niceeval.runner-diagnostics", "niceeval.file-changes", "niceeval.execution-traces", "niceeval.sources", "niceeval.artifacts"];
|
|
6
6
|
export type FixedRecordFamily = (typeof FIXED_RECORD_FAMILIES)[number];
|
|
7
7
|
export interface RecordByteIdentity {
|
|
8
8
|
readonly byteLength: number;
|
|
@@ -2,7 +2,7 @@ import type { AttemptId, CanonicalRunRelativePath, RecordId, RunId, Sha256Digest
|
|
|
2
2
|
export declare const SEAL_MANIFEST_FORMAT: "niceeval.seal-manifest";
|
|
3
3
|
export declare const PUBLISH_RECOVERY_FORMAT: "niceeval.publish-recovery";
|
|
4
4
|
/** Compatibility alias derived from the official branded definition catalog. */
|
|
5
|
-
export declare const FIXED_RECORD_FAMILIES: readonly ["niceeval.adapter-usage", "niceeval.assertions", "niceeval.attempt-cost", "niceeval.agent-turns", "niceeval.turn-contexts", "niceeval.sandbox-commands", "niceeval.runner-activities", "niceeval.runner-diagnostics", "niceeval.file-changes", "niceeval.execution-traces", "niceeval.sources", "niceeval.artifacts"];
|
|
5
|
+
export declare const FIXED_RECORD_FAMILIES: readonly ["niceeval.adapter-usage", "niceeval.judge-usage", "niceeval.assertions", "niceeval.attempt-cost", "niceeval.agent-turns", "niceeval.turn-contexts", "niceeval.sandbox-commands", "niceeval.runner-activities", "niceeval.runner-diagnostics", "niceeval.file-changes", "niceeval.execution-traces", "niceeval.sources", "niceeval.artifacts"];
|
|
6
6
|
export type FixedRecordFamily = (typeof FIXED_RECORD_FAMILIES)[number];
|
|
7
7
|
export interface RecordByteIdentity {
|
|
8
8
|
readonly byteLength: number;
|
|
@@ -2,7 +2,7 @@ import type { AttemptId, CanonicalRunRelativePath, RecordId, RunId, Sha256Digest
|
|
|
2
2
|
export declare const SEAL_MANIFEST_FORMAT: "niceeval.seal-manifest";
|
|
3
3
|
export declare const PUBLISH_RECOVERY_FORMAT: "niceeval.publish-recovery";
|
|
4
4
|
/** Compatibility alias derived from the official branded definition catalog. */
|
|
5
|
-
export declare const FIXED_RECORD_FAMILIES: readonly ["niceeval.adapter-usage", "niceeval.assertions", "niceeval.attempt-cost", "niceeval.agent-turns", "niceeval.turn-contexts", "niceeval.sandbox-commands", "niceeval.runner-activities", "niceeval.runner-diagnostics", "niceeval.file-changes", "niceeval.execution-traces", "niceeval.sources", "niceeval.artifacts"];
|
|
5
|
+
export declare const FIXED_RECORD_FAMILIES: readonly ["niceeval.adapter-usage", "niceeval.judge-usage", "niceeval.assertions", "niceeval.attempt-cost", "niceeval.agent-turns", "niceeval.turn-contexts", "niceeval.sandbox-commands", "niceeval.runner-activities", "niceeval.runner-diagnostics", "niceeval.file-changes", "niceeval.execution-traces", "niceeval.sources", "niceeval.artifacts"];
|
|
6
6
|
export type FixedRecordFamily = (typeof FIXED_RECORD_FAMILIES)[number];
|
|
7
7
|
export interface RecordByteIdentity {
|
|
8
8
|
readonly byteLength: number;
|
|
@@ -50,7 +50,8 @@ function requestTransferList(message) {
|
|
|
50
50
|
}
|
|
51
51
|
return buffers;
|
|
52
52
|
}
|
|
53
|
-
async function makeStorageWorkerClient(recordStorageRoot, busyTimeoutMs = 5000, databasePath = (0, database_ts_1.recordSqlitePath)(recordStorageRoot)) {
|
|
53
|
+
async function makeStorageWorkerClient(recordStorageRoot, busyTimeoutMs = 5000, databasePath = (0, database_ts_1.recordSqlitePath)(recordStorageRoot), initializationSignal) {
|
|
54
|
+
initializationSignal?.throwIfAborted();
|
|
54
55
|
const extension = __niceevalImportMetaUrl.endsWith(".ts") ? "ts" : "js";
|
|
55
56
|
const worker = new node_worker_threads_1.Worker(new URL(`./storage-worker.${extension}`, __niceevalImportMetaUrl), {
|
|
56
57
|
execArgv: (extension === "ts" ? ["--import", "tsx"] : process.execArgv.filter((argument) => !argument.startsWith("--input-type") && argument !== "--expose-gc" &&
|
|
@@ -60,6 +61,7 @@ async function makeStorageWorkerClient(recordStorageRoot, busyTimeoutMs = 5000,
|
|
|
60
61
|
let nextId = 1;
|
|
61
62
|
let closed = false;
|
|
62
63
|
let termination;
|
|
64
|
+
let closing;
|
|
63
65
|
const pending = new Map();
|
|
64
66
|
const rejectAll = (cause) => {
|
|
65
67
|
for (const request of pending.values())
|
|
@@ -72,7 +74,7 @@ async function makeStorageWorkerClient(recordStorageRoot, busyTimeoutMs = 5000,
|
|
|
72
74
|
return;
|
|
73
75
|
closed = true;
|
|
74
76
|
rejectAll(cause);
|
|
75
|
-
void terminate();
|
|
77
|
+
void terminate().catch(() => undefined);
|
|
76
78
|
};
|
|
77
79
|
const protocolFailure = (value) => new errors_ts_1.SqliteRecordError("record-sqlite-error", "worker-protocol", "Record storage worker returned an invalid response", { cause: value });
|
|
78
80
|
worker.on("message", (value) => {
|
|
@@ -118,14 +120,23 @@ async function makeStorageWorkerClient(recordStorageRoot, busyTimeoutMs = 5000,
|
|
|
118
120
|
}
|
|
119
121
|
});
|
|
120
122
|
};
|
|
123
|
+
const abortInitialization = () => fail(initializationSignal?.reason);
|
|
124
|
+
initializationSignal?.addEventListener("abort", abortInitialization, { once: true });
|
|
121
125
|
try {
|
|
126
|
+
initializationSignal?.throwIfAborted();
|
|
122
127
|
await request({ operation: "initialize", databasePath, busyTimeoutMs });
|
|
128
|
+
initializationSignal?.throwIfAborted();
|
|
129
|
+
if (closed)
|
|
130
|
+
throw new Error("Record storage worker closed during initialization");
|
|
123
131
|
}
|
|
124
132
|
catch (cause) {
|
|
125
133
|
fail(cause);
|
|
126
134
|
await terminate().catch(() => undefined);
|
|
127
135
|
throw cause;
|
|
128
136
|
}
|
|
137
|
+
finally {
|
|
138
|
+
initializationSignal?.removeEventListener("abort", abortInitialization);
|
|
139
|
+
}
|
|
129
140
|
return Object.freeze({
|
|
130
141
|
persistSealedRun: (input) => request({ operation: "persist-sealed-run", input }),
|
|
131
142
|
beginRun: async (input) => { await request({ operation: "begin-run", input }); },
|
|
@@ -157,9 +168,11 @@ async function makeStorageWorkerClient(recordStorageRoot, busyTimeoutMs = 5000,
|
|
|
157
168
|
invocation: (command) => request({ operation: "invocation", command }),
|
|
158
169
|
run: (command) => request({ operation: "run", command }),
|
|
159
170
|
admission: (command) => request({ operation: "admission", command }),
|
|
160
|
-
close: async () => {
|
|
161
|
-
if (closed)
|
|
171
|
+
close: () => closing ??= (async () => {
|
|
172
|
+
if (closed) {
|
|
173
|
+
await terminate();
|
|
162
174
|
return;
|
|
175
|
+
}
|
|
163
176
|
try {
|
|
164
177
|
await request({ operation: "close" });
|
|
165
178
|
}
|
|
@@ -168,7 +181,7 @@ async function makeStorageWorkerClient(recordStorageRoot, busyTimeoutMs = 5000,
|
|
|
168
181
|
rejectAll(new Error("Record storage worker is closed"));
|
|
169
182
|
await terminate();
|
|
170
183
|
}
|
|
171
|
-
},
|
|
184
|
+
})(),
|
|
172
185
|
});
|
|
173
186
|
}
|
|
174
187
|
function openStorageWorker(recordStorageRoot, busyTimeoutMs = 5000, databasePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["client.ts"],"names":[],"mappings":";;AAmFA,0DA2HC;AACD,8CAOC;AAtND,6DAA6C;AAC7C,mCAAuC;AACvC,2CAAyE;AACzE,+CAAiD;AAEjD,6DAAiN;AAqCjN,SAAS,gBAAgB,CAAC,KAAiB;IACvC,OAAO,KAAK,CAAC,MAAM,YAAY,WAAW,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU;QAChH,CAAC,CAAC,KAAK,CAAC,MAAM;QACd,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC;AACD,8FAA8F;AAC9F,SAAS,mBAAmB,CAAC,OAAyB;IAClD,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,CAAC,KAAiB,EAAQ,EAAE;QACpC,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC;IACF,IAAI,OAAO,CAAC,SAAS,KAAK,uBAAuB,EAAE,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM;YACpC,GAAG,CAAC,KAAK,CAAC,KA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K,EAAE,EAAE,CAAC,KAAK,YAAY,6BAAiB;YAChD,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,6BAAiB,CAAC,qBAAqB,EAAE,aAAa,EAAE,uCAAuC,EAAE,EAAE,KAAK,EAAE,CAAC;KACxH,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,eAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC","sourcesContent":["import { Worker } from \"node:worker_threads\";\nimport { Effect, Scope } from \"effect\";\nimport { isSqliteRecordErrorCode, SqliteRecordError } from \"./errors.ts\";\nimport { recordSqlitePath } from \"./database.ts\";\nimport type { AppendContentChunksInput, AdmitAttachmentInput, AdmitAttemptInput, AdmitContentInput, DiscardAttemptInput, BeginRunInput, ContentChunkPage, CollectionItemPage, FenceRunFinalizationInput, PersistSealedRunInput, PrepareRunFinalizationInput, PreparedRunFinalization, RunFinalization, SealedRunCore, SealedRunDocument, SealedRunSummary, SealRunInput, StageAttachmentReferencesInput, StageCollectionItemsInput, StageSealEntriesInput, StageSealEntriesResult, StageRunCoreInput, } from \"./types.ts\";\nimport { isStorageWorkerResponse, type CaseCoordinationCommand, type InvocationCommand, type RegistryCommand, type RunCommand, type StorageWorkerRequest, type StorageWorkerResult } from \"./worker-protocol.ts\";\nimport type { AdmissionInput } from \"../../coordination/platform/node-record-admission-protocol.ts\";\nexport interface StorageWorkerClient {\n readonly persistSealedRun: (input: PersistSealedRunInput) => Promise<SealedRunSummary>;\n readonly beginRun: (input: BeginRunInput) => Promise<void>;\n readonly admitAttempt: (input: AdmitAttemptInput) => Promise<void>;\n readonly discardAttempt: (input: DiscardAttemptInput) => Promise<void>;\n readonly admitAttachment: (input: AdmitAttachmentInput) => Promise<void>;\n readonly admitContent: (input: AdmitContentInput) => Promise<void>;\n readonly finalizeRun: (input: StageRunCoreInput) => Promise<RunFinalization>;\n readonly stageRunFinalMetadata: (input: StageRunCoreInput) => Promise<void>;\n readonly stageRunPublicationMetadata: (input: StageRunCoreInput) => Promise<void>;\n readonly prepareRunFinalization: (input: PrepareRunFinalizationInput) => Promise<PreparedRunFinalization>;\n readonly fenceRunFinalization: (input: FenceRunFinalizationInput) => Promise<RunFinalization>;\n readonly stageAttachmentReferences: (input: StageAttachmentReferencesInput) => Promise<void>;\n readonly stageCollectionItems: (input: StageCollectionItemsInput) => Promise<void>;\n readonly stageSealEntries: (input: StageSealEntriesInput) => Promise<StageSealEntriesResult>;\n /** Returns the exact transferred backing stores after SQLite has consumed them. */\n readonly appendContentChunks: (input: AppendContentChunksInput) => Promise<readonly Uint8Array[]>;\n readonly sealRun: (input: SealRunInput) => Promise<SealedRunSummary>;\n readonly publishRunSeal: (input: SealRunInput) => Promise<void>;\n readonly readSealedRunSummary: (runId: string) => Promise<SealedRunSummary | undefined>;\n readonly listSealedRunSummaries: (afterRunId?: string, pageSize?: number) => Promise<readonly SealedRunSummary[]>;\n readonly readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => Promise<CollectionItemPage>;\n readonly readSealedRunDocument: (runId: string) => Promise<SealedRunDocument | undefined>;\n readonly readSealedRunCore: (runId: string) => Promise<SealedRunCore | undefined>;\n readonly readRecordCore: () => Promise<Uint8Array | undefined>;\n readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => Promise<ContentChunkPage>;\n readonly validate: () => Promise<number>;\n readonly registry: <A extends StorageWorkerResult>(command: RegistryCommand, deadlineEpochMs: number) => Promise<A>;\n readonly caseCoordination: <A extends StorageWorkerResult>(command: CaseCoordinationCommand) => Promise<A>;\n readonly invocation: <A extends StorageWorkerResult>(command: InvocationCommand) => Promise<A>;\n readonly run: <A extends StorageWorkerResult>(command: RunCommand) => Promise<A>;\n readonly admission: <A extends StorageWorkerResult>(command: AdmissionInput) => Promise<A>;\n readonly close: () => Promise<void>;\n}\ntype RequestWithoutId = StorageWorkerRequest extends infer Request ? Request extends StorageWorkerRequest ? Omit<Request, \"id\"> : never : never;\nfunction ownedArrayBuffer(value: Uint8Array): ArrayBuffer | undefined {\n return value.buffer instanceof ArrayBuffer && value.byteOffset === 0 && value.byteLength === value.buffer.byteLength\n ? value.buffer\n : undefined;\n}\n/** Buffers listed here are immutable command payloads whose ownership ends at postMessage. */\nfunction requestTransferList(message: RequestWithoutId): readonly ArrayBuffer[] {\n const buffers: ArrayBuffer[] = [];\n const add = (value: Uint8Array): void => {\n const buffer = ownedArrayBuffer(value);\n if (buffer !== undefined && !buffers.includes(buffer))\n buffers.push(buffer);\n };\n if (message.operation === \"append-content-chunks\") {\n for (const chunk of message.input.chunks)\n add(chunk.bytes);\n }\n else if (message.operation === \"stage-collection-items\") {\n for (const item of message.input.items)\n add(item.canonicalBytes);\n }\n else if (message.operation === \"stage-attachment-references\") {\n for (const reference of message.input.references)\n add(reference.canonicalBytes);\n }\n else if (message.operation === \"stage-final-metadata\" || message.operation === \"finalize-run\") {\n add(message.input.recordCoreBytes);\n add(message.input.runCoreBytes);\n for (const slot of message.input.slots)\n add(slot.coreBytes);\n for (const attempt of message.input.attempts)\n add(attempt.coreBytes);\n for (const member of message.input.members)\n add(member.coreBytes);\n for (const attachment of message.input.attachments) {\n add(attachment.canonicalBytes);\n add(attachment.logicalInventoryBytes);\n }\n }\n return buffers;\n}\nexport async function makeStorageWorkerClient(recordStorageRoot: string, busyTimeoutMs = 5000, databasePath = recordSqlitePath(recordStorageRoot)): Promise<StorageWorkerClient> {\n const extension = __niceevalImportMetaUrl.endsWith(\".ts\") ? \"ts\" : \"js\";\n const worker = new Worker(new URL(`./storage-worker.${extension}`, __niceevalImportMetaUrl), {\n execArgv: (extension === \"ts\" ? [\"--import\", \"tsx\"] : process.execArgv.filter((argument) => !argument.startsWith(\"--input-type\") && argument !== \"--expose-gc\" &&\n !argument.startsWith(\"--max-old-space-size\") && !argument.startsWith(\"--max_old_space_size\") &&\n !argument.startsWith(\"--max-semi-space-size\") && !argument.startsWith(\"--max_semi_space_size\"))),\n });\n let nextId = 1;\n let closed = false;\n let termination: Promise<number> | undefined;\n const pending = new Map<number, {\n readonly resolve: (value: StorageWorkerResult) => void;\n readonly reject: (cause: unknown) => void;\n }>();\n const rejectAll = (cause: unknown): void => {\n for (const request of pending.values())\n request.reject(cause);\n pending.clear();\n };\n const terminate = (): Promise<number> => termination ??= worker.terminate();\n const fail = (cause: unknown): void => {\n if (closed)\n return;\n closed = true;\n rejectAll(cause);\n void terminate();\n };\n const protocolFailure = (value: unknown): SqliteRecordError => new SqliteRecordError(\"record-sqlite-error\", \"worker-protocol\", \"Record storage worker returned an invalid response\", { cause: value });\n worker.on(\"message\", (value: unknown) => {\n if (!isStorageWorkerResponse(value)) {\n fail(protocolFailure(value));\n return;\n }\n const request = pending.get(value.id);\n if (request === undefined) {\n fail(protocolFailure(value));\n return;\n }\n pending.delete(value.id);\n if (value.state === \"success\") {\n request.resolve(value.result);\n return;\n }\n const remoteCause = new Error(value.error.message);\n remoteCause.name = value.error.code;\n if (value.error.stack !== undefined)\n remoteCause.stack = value.error.stack;\n if (value.error.details !== undefined)\n Reflect.set(remoteCause, \"details\", value.error.details);\n request.reject(new SqliteRecordError(isSqliteRecordErrorCode(value.error.code) ? value.error.code : \"record-sqlite-error\", value.error.operation, value.error.message, { cause: remoteCause }));\n });\n worker.on(\"error\", fail);\n worker.on(\"exit\", (code) => {\n if (!closed)\n fail(new Error(`Record storage worker exited unexpectedly with code ${code}`));\n });\n const request = <Result extends StorageWorkerResult>(message: RequestWithoutId): Promise<Result> => {\n if (closed)\n return Promise.reject(new Error(\"Record storage worker is closed\"));\n const id = nextId++;\n return new Promise<Result>((resolve, reject) => {\n pending.set(id, { resolve: (value) => resolve(value as Result), reject });\n try {\n worker.postMessage({ ...message, id }, requestTransferList(message));\n }\n catch (cause) {\n pending.delete(id);\n reject(cause);\n }\n });\n };\n try {\n await request<undefined>({ operation: \"initialize\", databasePath, busyTimeoutMs });\n }\n catch (cause) {\n fail(cause);\n await terminate().catch(() => undefined);\n throw cause;\n }\n return Object.freeze({\n persistSealedRun: (input: PersistSealedRunInput) => request<SealedRunSummary>({ operation: \"persist-sealed-run\", input }),\n beginRun: async (input: BeginRunInput) => { await request<undefined>({ operation: \"begin-run\", input }); },\n admitAttempt: async (input: AdmitAttemptInput) => { await request<undefined>({ operation: \"admit-attempt\", input }); },\n discardAttempt: async (input: DiscardAttemptInput) => { await request<undefined>({ operation: \"discard-attempt\", input }); },\n admitAttachment: async (input: AdmitAttachmentInput) => { await request<undefined>({ operation: \"admit-attachment\", input }); },\n admitContent: async (input: AdmitContentInput) => { await request<undefined>({ operation: \"admit-content\", input }); },\n finalizeRun: (input: StageRunCoreInput) => request<RunFinalization>({ operation: \"finalize-run\", input }),\n stageRunFinalMetadata: async (input: StageRunCoreInput) => { await request<undefined>({ operation: \"stage-final-metadata\", input }); },\n stageRunPublicationMetadata: async (input: StageRunCoreInput) => { await request<undefined>({ operation: \"stage-publication-metadata\", input }); },\n prepareRunFinalization: (input: PrepareRunFinalizationInput) => request<PreparedRunFinalization>({ operation: \"prepare-finalization\", input }),\n fenceRunFinalization: (input: FenceRunFinalizationInput) => request<RunFinalization>({ operation: \"fence-finalization\", input }),\n stageAttachmentReferences: async (input: StageAttachmentReferencesInput) => { await request<undefined>({ operation: \"stage-attachment-references\", input }); },\n stageCollectionItems: async (input: StageCollectionItemsInput) => { await request<undefined>({ operation: \"stage-collection-items\", input }); },\n stageSealEntries: (input: StageSealEntriesInput) => request<StageSealEntriesResult>({ operation: \"stage-seal-entries\", input }),\n appendContentChunks: (input: AppendContentChunksInput) => request<readonly Uint8Array[]>({ operation: \"append-content-chunks\", input }),\n sealRun: (input: SealRunInput) => request<SealedRunSummary>({ operation: \"seal-run\", input }),\n publishRunSeal: async (input: SealRunInput) => { await request<undefined>({ operation: \"publish-run-seal\", input }); },\n readSealedRunSummary: (runId: string) => request<SealedRunSummary | undefined>({ operation: \"read-sealed-run-summary\", runId }),\n listSealedRunSummaries: (afterRunId = \"\", pageSize = 100) => request<readonly SealedRunSummary[]>({ operation: \"list-sealed-run-summaries\", afterRunId, pageSize }),\n readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => request<CollectionItemPage>({ operation: \"read-collection-item-page\", attachmentId, afterOrdinal, pageSize }),\n readSealedRunDocument: (runId: string) => request<SealedRunDocument | undefined>({ operation: \"read-sealed-run-document\", runId }),\n readSealedRunCore: (runId: string) => request<SealedRunCore | undefined>({ operation: \"read-sealed-run-core\", runId }),\n readRecordCore: () => request<Uint8Array | undefined>({ operation: \"read-record-core\" }),\n readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => request<ContentChunkPage>({ operation: \"read-content-chunk-page\", contentId, afterOrdinal, pageSize }),\n validate: () => request<number>({ operation: \"validate\" }),\n registry: <A extends StorageWorkerResult>(command: RegistryCommand, deadlineEpochMs: number) => request<A>({ operation: \"registry\", command, deadlineEpochMs }),\n caseCoordination: <A extends StorageWorkerResult>(command: CaseCoordinationCommand) => request<A>({ operation: \"case-coordination\", command }),\n invocation: <A extends StorageWorkerResult>(command: InvocationCommand) => request<A>({ operation: \"invocation\", command }),\n run: <A extends StorageWorkerResult>(command: RunCommand) => request<A>({ operation: \"run\", command }),\n admission: <A extends StorageWorkerResult>(command: AdmissionInput) => request<A>({ operation: \"admission\", command }),\n close: async () => {\n if (closed)\n return;\n try {\n await request<undefined>({ operation: \"close\" });\n }\n finally {\n closed = true;\n rejectAll(new Error(\"Record storage worker is closed\"));\n await terminate();\n }\n },\n });\n}\nexport function openStorageWorker(recordStorageRoot: string, busyTimeoutMs = 5000, databasePath?: string): Effect.Effect<StorageWorkerClient, SqliteRecordError, Scope.Scope> {\n return Effect.acquireRelease(Effect.tryPromise({\n try: () => makeStorageWorkerClient(recordStorageRoot, busyTimeoutMs, databasePath),\n catch: (cause) => cause instanceof SqliteRecordError\n ? cause\n : new SqliteRecordError(\"record-sqlite-error\", \"open-worker\", \"failed to start Record storage worker\", { cause }),\n }), (client) => Effect.promise(() => client.close().catch(() => undefined)));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["client.ts"],"names":[],"mappings":";;AAmFA,0DAwIC;AACD,8CAOC;AAnOD,6DAA6C;AAC7C,mCAAuC;AACvC,2CAAyE;AACzE,+CAAiD;AAEjD,6DAAiN;AAqCjN,SAAS,gBAAgB,CAAC,KAAiB;IACvC,OAAO,KAAK,CAAC,MAAM,YAAY,WAAW,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,MAAM,CAAC,UAAU;QAChH,CAAC,CAAC,KAAK,CAAC,MAAM;QACd,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC;AACD,8FAA8F;AAC9F,SAAS,mBAAmB,CAAC,OAAyB;IAClD,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,MAAM,GAAG,GAAG,CAAC,KAAiB,EAAQ,EAAE;QACpC,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC;IACF,IAAI,OAAO,CAAC,SAAS,KAAK,uBAAuB,EAAE,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM;YACpC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;SACI,IAAI,OAAO,CAAC,SAAS,KAAK,wBAAwB,EAAE,CAAC;QACtD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK;YAClC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACjC,CAAC;SACI,IAAI,OAAO,CAAC,SAAS,KAAK,6B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AI,CAAC;gBACd,SAAS,CAAC,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC,CAAC;gBACxD,MAAM,SAAS,EAAE,CAAC;YACtB,CAAC;QACL,CAAC,CAAC,EAAE;KACP,CAAC,CAAC;AACP,CAAC;AACD,SAAgB,iBAAiB,CAAC,iBAAyB,EAAE,aAAa,GAAG,IAAI,EAAE,YAAqB;IACpG,OAAO,eAAM,CAAC,cAAc,CAAC,eAAM,CAAC,UAAU,CAAC;QAC3C,GAAG,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,iBAAiB,EAAE,aAAa,EAAE,YAAY,CAAC;QAClF,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,YAAY,6BAAiB;YAChD,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,6BAAiB,CAAC,qBAAqB,EAAE,aAAa,EAAE,uCAAuC,EAAE,EAAE,KAAK,EAAE,CAAC;KACxH,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,eAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC","sourcesContent":["import { Worker } from \"node:worker_threads\";\nimport { Effect, Scope } from \"effect\";\nimport { isSqliteRecordErrorCode, SqliteRecordError } from \"./errors.ts\";\nimport { recordSqlitePath } from \"./database.ts\";\nimport type { AppendContentChunksInput, AdmitAttachmentInput, AdmitAttemptInput, AdmitContentInput, DiscardAttemptInput, BeginRunInput, ContentChunkPage, CollectionItemPage, FenceRunFinalizationInput, PersistSealedRunInput, PrepareRunFinalizationInput, PreparedRunFinalization, RunFinalization, SealedRunCore, SealedRunDocument, SealedRunSummary, SealRunInput, StageAttachmentReferencesInput, StageCollectionItemsInput, StageSealEntriesInput, StageSealEntriesResult, StageRunCoreInput, } from \"./types.ts\";\nimport { isStorageWorkerResponse, type CaseCoordinationCommand, type InvocationCommand, type RegistryCommand, type RunCommand, type StorageWorkerRequest, type StorageWorkerResult } from \"./worker-protocol.ts\";\nimport type { AdmissionInput } from \"../../coordination/platform/node-record-admission-protocol.ts\";\nexport interface StorageWorkerClient {\n readonly persistSealedRun: (input: PersistSealedRunInput) => Promise<SealedRunSummary>;\n readonly beginRun: (input: BeginRunInput) => Promise<void>;\n readonly admitAttempt: (input: AdmitAttemptInput) => Promise<void>;\n readonly discardAttempt: (input: DiscardAttemptInput) => Promise<void>;\n readonly admitAttachment: (input: AdmitAttachmentInput) => Promise<void>;\n readonly admitContent: (input: AdmitContentInput) => Promise<void>;\n readonly finalizeRun: (input: StageRunCoreInput) => Promise<RunFinalization>;\n readonly stageRunFinalMetadata: (input: StageRunCoreInput) => Promise<void>;\n readonly stageRunPublicationMetadata: (input: StageRunCoreInput) => Promise<void>;\n readonly prepareRunFinalization: (input: PrepareRunFinalizationInput) => Promise<PreparedRunFinalization>;\n readonly fenceRunFinalization: (input: FenceRunFinalizationInput) => Promise<RunFinalization>;\n readonly stageAttachmentReferences: (input: StageAttachmentReferencesInput) => Promise<void>;\n readonly stageCollectionItems: (input: StageCollectionItemsInput) => Promise<void>;\n readonly stageSealEntries: (input: StageSealEntriesInput) => Promise<StageSealEntriesResult>;\n /** Returns the exact transferred backing stores after SQLite has consumed them. */\n readonly appendContentChunks: (input: AppendContentChunksInput) => Promise<readonly Uint8Array[]>;\n readonly sealRun: (input: SealRunInput) => Promise<SealedRunSummary>;\n readonly publishRunSeal: (input: SealRunInput) => Promise<void>;\n readonly readSealedRunSummary: (runId: string) => Promise<SealedRunSummary | undefined>;\n readonly listSealedRunSummaries: (afterRunId?: string, pageSize?: number) => Promise<readonly SealedRunSummary[]>;\n readonly readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => Promise<CollectionItemPage>;\n readonly readSealedRunDocument: (runId: string) => Promise<SealedRunDocument | undefined>;\n readonly readSealedRunCore: (runId: string) => Promise<SealedRunCore | undefined>;\n readonly readRecordCore: () => Promise<Uint8Array | undefined>;\n readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => Promise<ContentChunkPage>;\n readonly validate: () => Promise<number>;\n readonly registry: <A extends StorageWorkerResult>(command: RegistryCommand, deadlineEpochMs: number) => Promise<A>;\n readonly caseCoordination: <A extends StorageWorkerResult>(command: CaseCoordinationCommand) => Promise<A>;\n readonly invocation: <A extends StorageWorkerResult>(command: InvocationCommand) => Promise<A>;\n readonly run: <A extends StorageWorkerResult>(command: RunCommand) => Promise<A>;\n readonly admission: <A extends StorageWorkerResult>(command: AdmissionInput) => Promise<A>;\n readonly close: () => Promise<void>;\n}\ntype RequestWithoutId = StorageWorkerRequest extends infer Request ? Request extends StorageWorkerRequest ? Omit<Request, \"id\"> : never : never;\nfunction ownedArrayBuffer(value: Uint8Array): ArrayBuffer | undefined {\n return value.buffer instanceof ArrayBuffer && value.byteOffset === 0 && value.byteLength === value.buffer.byteLength\n ? value.buffer\n : undefined;\n}\n/** Buffers listed here are immutable command payloads whose ownership ends at postMessage. */\nfunction requestTransferList(message: RequestWithoutId): readonly ArrayBuffer[] {\n const buffers: ArrayBuffer[] = [];\n const add = (value: Uint8Array): void => {\n const buffer = ownedArrayBuffer(value);\n if (buffer !== undefined && !buffers.includes(buffer))\n buffers.push(buffer);\n };\n if (message.operation === \"append-content-chunks\") {\n for (const chunk of message.input.chunks)\n add(chunk.bytes);\n }\n else if (message.operation === \"stage-collection-items\") {\n for (const item of message.input.items)\n add(item.canonicalBytes);\n }\n else if (message.operation === \"stage-attachment-references\") {\n for (const reference of message.input.references)\n add(reference.canonicalBytes);\n }\n else if (message.operation === \"stage-final-metadata\" || message.operation === \"finalize-run\") {\n add(message.input.recordCoreBytes);\n add(message.input.runCoreBytes);\n for (const slot of message.input.slots)\n add(slot.coreBytes);\n for (const attempt of message.input.attempts)\n add(attempt.coreBytes);\n for (const member of message.input.members)\n add(member.coreBytes);\n for (const attachment of message.input.attachments) {\n add(attachment.canonicalBytes);\n add(attachment.logicalInventoryBytes);\n }\n }\n return buffers;\n}\nexport async function makeStorageWorkerClient(recordStorageRoot: string, busyTimeoutMs = 5000, databasePath = recordSqlitePath(recordStorageRoot), initializationSignal?: AbortSignal): Promise<StorageWorkerClient> {\n initializationSignal?.throwIfAborted();\n const extension = __niceevalImportMetaUrl.endsWith(\".ts\") ? \"ts\" : \"js\";\n const worker = new Worker(new URL(`./storage-worker.${extension}`, __niceevalImportMetaUrl), {\n execArgv: (extension === \"ts\" ? [\"--import\", \"tsx\"] : process.execArgv.filter((argument) => !argument.startsWith(\"--input-type\") && argument !== \"--expose-gc\" &&\n !argument.startsWith(\"--max-old-space-size\") && !argument.startsWith(\"--max_old_space_size\") &&\n !argument.startsWith(\"--max-semi-space-size\") && !argument.startsWith(\"--max_semi_space_size\"))),\n });\n let nextId = 1;\n let closed = false;\n let termination: Promise<number> | undefined;\n let closing: Promise<void> | undefined;\n const pending = new Map<number, {\n readonly resolve: (value: StorageWorkerResult) => void;\n readonly reject: (cause: unknown) => void;\n }>();\n const rejectAll = (cause: unknown): void => {\n for (const request of pending.values())\n request.reject(cause);\n pending.clear();\n };\n const terminate = (): Promise<number> => termination ??= worker.terminate();\n const fail = (cause: unknown): void => {\n if (closed)\n return;\n closed = true;\n rejectAll(cause);\n void terminate().catch(() => undefined);\n };\n const protocolFailure = (value: unknown): SqliteRecordError => new SqliteRecordError(\"record-sqlite-error\", \"worker-protocol\", \"Record storage worker returned an invalid response\", { cause: value });\n worker.on(\"message\", (value: unknown) => {\n if (!isStorageWorkerResponse(value)) {\n fail(protocolFailure(value));\n return;\n }\n const request = pending.get(value.id);\n if (request === undefined) {\n fail(protocolFailure(value));\n return;\n }\n pending.delete(value.id);\n if (value.state === \"success\") {\n request.resolve(value.result);\n return;\n }\n const remoteCause = new Error(value.error.message);\n remoteCause.name = value.error.code;\n if (value.error.stack !== undefined)\n remoteCause.stack = value.error.stack;\n if (value.error.details !== undefined)\n Reflect.set(remoteCause, \"details\", value.error.details);\n request.reject(new SqliteRecordError(isSqliteRecordErrorCode(value.error.code) ? value.error.code : \"record-sqlite-error\", value.error.operation, value.error.message, { cause: remoteCause }));\n });\n worker.on(\"error\", fail);\n worker.on(\"exit\", (code) => {\n if (!closed)\n fail(new Error(`Record storage worker exited unexpectedly with code ${code}`));\n });\n const request = <Result extends StorageWorkerResult>(message: RequestWithoutId): Promise<Result> => {\n if (closed)\n return Promise.reject(new Error(\"Record storage worker is closed\"));\n const id = nextId++;\n return new Promise<Result>((resolve, reject) => {\n pending.set(id, { resolve: (value) => resolve(value as Result), reject });\n try {\n worker.postMessage({ ...message, id }, requestTransferList(message));\n }\n catch (cause) {\n pending.delete(id);\n reject(cause);\n }\n });\n };\n const abortInitialization = () => fail(initializationSignal?.reason);\n initializationSignal?.addEventListener(\"abort\", abortInitialization, { once: true });\n try {\n initializationSignal?.throwIfAborted();\n await request<undefined>({ operation: \"initialize\", databasePath, busyTimeoutMs });\n initializationSignal?.throwIfAborted();\n if (closed)\n throw new Error(\"Record storage worker closed during initialization\");\n }\n catch (cause) {\n fail(cause);\n await terminate().catch(() => undefined);\n throw cause;\n }\n finally {\n initializationSignal?.removeEventListener(\"abort\", abortInitialization);\n }\n return Object.freeze({\n persistSealedRun: (input: PersistSealedRunInput) => request<SealedRunSummary>({ operation: \"persist-sealed-run\", input }),\n beginRun: async (input: BeginRunInput) => { await request<undefined>({ operation: \"begin-run\", input }); },\n admitAttempt: async (input: AdmitAttemptInput) => { await request<undefined>({ operation: \"admit-attempt\", input }); },\n discardAttempt: async (input: DiscardAttemptInput) => { await request<undefined>({ operation: \"discard-attempt\", input }); },\n admitAttachment: async (input: AdmitAttachmentInput) => { await request<undefined>({ operation: \"admit-attachment\", input }); },\n admitContent: async (input: AdmitContentInput) => { await request<undefined>({ operation: \"admit-content\", input }); },\n finalizeRun: (input: StageRunCoreInput) => request<RunFinalization>({ operation: \"finalize-run\", input }),\n stageRunFinalMetadata: async (input: StageRunCoreInput) => { await request<undefined>({ operation: \"stage-final-metadata\", input }); },\n stageRunPublicationMetadata: async (input: StageRunCoreInput) => { await request<undefined>({ operation: \"stage-publication-metadata\", input }); },\n prepareRunFinalization: (input: PrepareRunFinalizationInput) => request<PreparedRunFinalization>({ operation: \"prepare-finalization\", input }),\n fenceRunFinalization: (input: FenceRunFinalizationInput) => request<RunFinalization>({ operation: \"fence-finalization\", input }),\n stageAttachmentReferences: async (input: StageAttachmentReferencesInput) => { await request<undefined>({ operation: \"stage-attachment-references\", input }); },\n stageCollectionItems: async (input: StageCollectionItemsInput) => { await request<undefined>({ operation: \"stage-collection-items\", input }); },\n stageSealEntries: (input: StageSealEntriesInput) => request<StageSealEntriesResult>({ operation: \"stage-seal-entries\", input }),\n appendContentChunks: (input: AppendContentChunksInput) => request<readonly Uint8Array[]>({ operation: \"append-content-chunks\", input }),\n sealRun: (input: SealRunInput) => request<SealedRunSummary>({ operation: \"seal-run\", input }),\n publishRunSeal: async (input: SealRunInput) => { await request<undefined>({ operation: \"publish-run-seal\", input }); },\n readSealedRunSummary: (runId: string) => request<SealedRunSummary | undefined>({ operation: \"read-sealed-run-summary\", runId }),\n listSealedRunSummaries: (afterRunId = \"\", pageSize = 100) => request<readonly SealedRunSummary[]>({ operation: \"list-sealed-run-summaries\", afterRunId, pageSize }),\n readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => request<CollectionItemPage>({ operation: \"read-collection-item-page\", attachmentId, afterOrdinal, pageSize }),\n readSealedRunDocument: (runId: string) => request<SealedRunDocument | undefined>({ operation: \"read-sealed-run-document\", runId }),\n readSealedRunCore: (runId: string) => request<SealedRunCore | undefined>({ operation: \"read-sealed-run-core\", runId }),\n readRecordCore: () => request<Uint8Array | undefined>({ operation: \"read-record-core\" }),\n readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => request<ContentChunkPage>({ operation: \"read-content-chunk-page\", contentId, afterOrdinal, pageSize }),\n validate: () => request<number>({ operation: \"validate\" }),\n registry: <A extends StorageWorkerResult>(command: RegistryCommand, deadlineEpochMs: number) => request<A>({ operation: \"registry\", command, deadlineEpochMs }),\n caseCoordination: <A extends StorageWorkerResult>(command: CaseCoordinationCommand) => request<A>({ operation: \"case-coordination\", command }),\n invocation: <A extends StorageWorkerResult>(command: InvocationCommand) => request<A>({ operation: \"invocation\", command }),\n run: <A extends StorageWorkerResult>(command: RunCommand) => request<A>({ operation: \"run\", command }),\n admission: <A extends StorageWorkerResult>(command: AdmissionInput) => request<A>({ operation: \"admission\", command }),\n close: () => closing ??= (async () => {\n if (closed) {\n await terminate();\n return;\n }\n try {\n await request<undefined>({ operation: \"close\" });\n }\n finally {\n closed = true;\n rejectAll(new Error(\"Record storage worker is closed\"));\n await terminate();\n }\n })(),\n });\n}\nexport function openStorageWorker(recordStorageRoot: string, busyTimeoutMs = 5000, databasePath?: string): Effect.Effect<StorageWorkerClient, SqliteRecordError, Scope.Scope> {\n return Effect.acquireRelease(Effect.tryPromise({\n try: () => makeStorageWorkerClient(recordStorageRoot, busyTimeoutMs, databasePath),\n catch: (cause) => cause instanceof SqliteRecordError\n ? cause\n : new SqliteRecordError(\"record-sqlite-error\", \"open-worker\", \"failed to start Record storage worker\", { cause }),\n }), (client) => Effect.promise(() => client.close().catch(() => undefined)));\n}\n"]}
|
|
@@ -37,5 +37,5 @@ export interface StorageWorkerClient {
|
|
|
37
37
|
readonly admission: <A extends StorageWorkerResult>(command: AdmissionInput) => Promise<A>;
|
|
38
38
|
readonly close: () => Promise<void>;
|
|
39
39
|
}
|
|
40
|
-
export declare function makeStorageWorkerClient(recordStorageRoot: string, busyTimeoutMs?: number, databasePath?: string): Promise<StorageWorkerClient>;
|
|
40
|
+
export declare function makeStorageWorkerClient(recordStorageRoot: string, busyTimeoutMs?: number, databasePath?: string, initializationSignal?: AbortSignal): Promise<StorageWorkerClient>;
|
|
41
41
|
export declare function openStorageWorker(recordStorageRoot: string, busyTimeoutMs?: number, databasePath?: string): Effect.Effect<StorageWorkerClient, SqliteRecordError, Scope.Scope>;
|
|
@@ -37,5 +37,5 @@ export interface StorageWorkerClient {
|
|
|
37
37
|
readonly admission: <A extends StorageWorkerResult>(command: AdmissionInput) => Promise<A>;
|
|
38
38
|
readonly close: () => Promise<void>;
|
|
39
39
|
}
|
|
40
|
-
export declare function makeStorageWorkerClient(recordStorageRoot: string, busyTimeoutMs?: number, databasePath?: string): Promise<StorageWorkerClient>;
|
|
40
|
+
export declare function makeStorageWorkerClient(recordStorageRoot: string, busyTimeoutMs?: number, databasePath?: string, initializationSignal?: AbortSignal): Promise<StorageWorkerClient>;
|
|
41
41
|
export declare function openStorageWorker(recordStorageRoot: string, busyTimeoutMs?: number, databasePath?: string): Effect.Effect<StorageWorkerClient, SqliteRecordError, Scope.Scope>;
|
|
@@ -37,5 +37,5 @@ export interface StorageWorkerClient {
|
|
|
37
37
|
readonly admission: <A extends StorageWorkerResult>(command: AdmissionInput) => Promise<A>;
|
|
38
38
|
readonly close: () => Promise<void>;
|
|
39
39
|
}
|
|
40
|
-
export declare function makeStorageWorkerClient(recordStorageRoot: string, busyTimeoutMs?: number, databasePath?: string): Promise<StorageWorkerClient>;
|
|
40
|
+
export declare function makeStorageWorkerClient(recordStorageRoot: string, busyTimeoutMs?: number, databasePath?: string, initializationSignal?: AbortSignal): Promise<StorageWorkerClient>;
|
|
41
41
|
export declare function openStorageWorker(recordStorageRoot: string, busyTimeoutMs?: number, databasePath?: string): Effect.Effect<StorageWorkerClient, SqliteRecordError, Scope.Scope>;
|