niceeval 0.13.1 → 0.13.2
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 +25 -2
- package/README.md +9 -10
- package/README.zh.md +9 -10
- package/dist/agents/ai-sdk.cjs.map +1 -1
- package/dist/agents/ai-sdk.d.cts +1 -1
- package/dist/agents/ai-sdk.d.mts +1 -1
- package/dist/agents/ai-sdk.d.ts +1 -1
- package/dist/agents/bub-install-spec.cjs +19 -5
- package/dist/agents/bub-install-spec.cjs.map +1 -1
- package/dist/agents/bub-install-spec.d.cts +9 -2
- package/dist/agents/bub-install-spec.d.mts +9 -2
- package/dist/agents/bub-install-spec.d.ts +9 -2
- package/dist/agents/bub-install-spec.js +14 -12
- package/dist/agents/bub.cjs +10 -6
- package/dist/agents/bub.cjs.map +1 -1
- package/dist/agents/bub.d.cts +2 -2
- package/dist/agents/bub.d.mts +2 -2
- package/dist/agents/bub.d.ts +2 -2
- package/dist/agents/claude-code.cjs.map +1 -1
- package/dist/agents/claude-code.d.cts +2 -2
- package/dist/agents/claude-code.d.mts +2 -2
- package/dist/agents/claude-code.d.ts +2 -2
- package/dist/agents/codex.cjs +4 -4
- package/dist/agents/codex.cjs.map +1 -1
- package/dist/agents/codex.d.cts +3 -3
- package/dist/agents/codex.d.mts +3 -3
- package/dist/agents/codex.d.ts +3 -3
- package/dist/agents/coding-cli-versions.cjs +10 -1
- package/dist/agents/coding-cli-versions.cjs.map +1 -1
- package/dist/agents/coding-cli-versions.d.cts +8 -3
- package/dist/agents/coding-cli-versions.d.mts +8 -3
- package/dist/agents/coding-cli-versions.d.ts +8 -3
- package/dist/agents/coding-cli-versions.js +18 -12
- package/dist/agents/deepseek-harness.cjs +151 -0
- package/dist/agents/deepseek-harness.cjs.map +1 -0
- package/dist/agents/deepseek-harness.d.cts +14 -0
- package/dist/agents/deepseek-harness.d.mts +14 -0
- package/dist/agents/deepseek-harness.d.ts +14 -0
- package/dist/agents/deepseek-harness.js +7 -0
- package/dist/agents/deepseek-harness.js.map +1 -0
- package/dist/agents/exact-npm-plugins.cjs +28 -0
- package/dist/agents/exact-npm-plugins.cjs.map +1 -0
- package/dist/agents/exact-npm-plugins.d.cts +10 -0
- package/dist/agents/exact-npm-plugins.d.mts +10 -0
- package/dist/agents/exact-npm-plugins.d.ts +10 -0
- package/dist/agents/exact-npm-plugins.js +8 -0
- package/dist/agents/exact-npm-plugins.js.map +1 -0
- package/dist/agents/index.cjs +5 -1
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +4 -0
- package/dist/agents/index.d.mts +4 -0
- package/dist/agents/index.d.ts +4 -0
- package/dist/agents/index.js +54 -50
- package/dist/agents/index.mjs +54 -50
- package/dist/agents/omp.cjs +170 -0
- package/dist/agents/omp.cjs.map +1 -0
- package/dist/agents/omp.d.cts +14 -0
- package/dist/agents/omp.d.mts +14 -0
- package/dist/agents/omp.d.ts +14 -0
- package/dist/agents/omp.js +7 -0
- package/dist/agents/omp.js.map +1 -0
- package/dist/agents/openclaw.cjs +51 -2
- package/dist/agents/openclaw.cjs.map +1 -1
- package/dist/agents/openclaw.d.cts +2 -0
- package/dist/agents/openclaw.d.mts +2 -0
- package/dist/agents/openclaw.d.ts +2 -0
- package/dist/agents/types.cjs.map +1 -1
- package/dist/agents/types.d.cts +4 -4
- package/dist/agents/types.d.mts +4 -4
- package/dist/agents/types.d.ts +4 -4
- package/dist/agents/ui-message-stream.cjs +24 -7
- package/dist/agents/ui-message-stream.cjs.map +1 -1
- package/dist/analysis/api.cjs +28 -2
- package/dist/analysis/api.cjs.map +1 -1
- package/dist/analysis/api.d.cts +22 -1
- package/dist/analysis/api.d.mts +22 -1
- package/dist/analysis/api.d.ts +22 -1
- package/dist/analysis/api.js +8 -6
- package/dist/analysis/bindings.cjs +11 -18
- package/dist/analysis/bindings.cjs.map +1 -1
- package/dist/analysis/bindings.d.cts +177 -49
- package/dist/analysis/bindings.d.mts +177 -49
- package/dist/analysis/bindings.d.ts +177 -49
- package/dist/analysis/contracts.cjs +1 -0
- package/dist/analysis/contracts.cjs.map +1 -1
- package/dist/analysis/contracts.d.cts +43 -3
- package/dist/analysis/contracts.d.mts +43 -3
- package/dist/analysis/contracts.d.ts +43 -3
- package/dist/analysis/cost-projection.cjs +2 -1
- package/dist/analysis/cost-projection.cjs.map +1 -1
- package/dist/analysis/cost-projection.d.cts +1 -1
- package/dist/analysis/cost-projection.d.mts +1 -1
- package/dist/analysis/cost-projection.d.ts +1 -1
- package/dist/analysis/cost.cjs +13 -3
- package/dist/analysis/cost.cjs.map +1 -1
- package/dist/analysis/cost.d.cts +10 -3
- package/dist/analysis/cost.d.mts +10 -3
- package/dist/analysis/cost.d.ts +10 -3
- package/dist/analysis/experiment-groups.cjs +96 -0
- package/dist/analysis/experiment-groups.cjs.map +1 -0
- package/dist/analysis/experiment-groups.d.cts +9 -0
- package/dist/analysis/experiment-groups.d.mts +9 -0
- package/dist/analysis/experiment-groups.d.ts +9 -0
- package/dist/analysis/experiment-groups.js +10 -0
- package/dist/analysis/experiment-groups.js.map +1 -0
- package/dist/analysis/index.cjs +4 -1
- package/dist/analysis/index.cjs.map +1 -1
- package/dist/analysis/index.d.cts +4 -2
- package/dist/analysis/index.d.mts +4 -2
- package/dist/analysis/index.d.ts +4 -2
- package/dist/analysis/index.js +40 -36
- package/dist/analysis/index.mjs +40 -36
- package/dist/assertions/limits.cjs +4 -0
- package/dist/assertions/limits.cjs.map +1 -1
- package/dist/assertions/limits.d.cts +4 -0
- package/dist/assertions/limits.d.mts +4 -0
- package/dist/assertions/limits.d.ts +4 -0
- package/dist/assertions/match.cjs +63 -25
- package/dist/assertions/match.cjs.map +1 -1
- package/dist/assertions/match.d.cts +7 -0
- package/dist/assertions/match.d.mts +7 -0
- package/dist/assertions/match.d.ts +7 -0
- package/dist/assertions/record/attachment.cjs +32 -4
- package/dist/assertions/record/attachment.cjs.map +1 -1
- package/dist/assertions/record/diff.cjs +10 -4
- package/dist/assertions/record/diff.cjs.map +1 -1
- package/dist/assertions/record/producer.cjs +101 -4
- package/dist/assertions/record/producer.cjs.map +1 -1
- package/dist/assertions/record/producer.d.cts +4 -1
- package/dist/assertions/record/producer.d.mts +4 -1
- package/dist/assertions/record/producer.d.ts +4 -1
- package/dist/assertions/runtime.cjs +45 -5
- package/dist/assertions/runtime.cjs.map +1 -1
- package/dist/cli/record.cjs +113 -8
- package/dist/cli/record.cjs.map +1 -1
- package/dist/cli/record.d.cts +20 -1
- package/dist/cli/record.d.mts +20 -1
- package/dist/cli/record.d.ts +20 -1
- package/dist/cli/record.js +4 -2
- package/dist/cli.cjs +386 -31
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +10 -2
- package/dist/cli.d.mts +10 -2
- package/dist/cli.d.ts +10 -2
- package/dist/context/send-retry.cjs +4 -4
- package/dist/context/send-retry.cjs.map +1 -1
- package/dist/coordination/host/runtime.cjs +8 -30
- package/dist/coordination/host/runtime.cjs.map +1 -1
- package/dist/coordination/host/runtime.d.cts +3 -3
- package/dist/coordination/host/runtime.d.mts +3 -3
- package/dist/coordination/host/runtime.d.ts +3 -3
- package/dist/coordination/host/types.cjs.map +1 -1
- package/dist/coordination/host/types.d.cts +0 -5
- package/dist/coordination/host/types.d.mts +0 -5
- package/dist/coordination/host/types.d.ts +0 -5
- package/dist/coordination/platform/node.cjs +90 -9
- package/dist/coordination/platform/node.cjs.map +1 -1
- package/dist/define.cjs +25 -1
- package/dist/define.cjs.map +1 -1
- package/dist/experiment/host/index.cjs +1 -0
- package/dist/experiment/host/index.cjs.map +1 -1
- package/dist/i18n/en.cjs +26 -8
- package/dist/i18n/en.cjs.map +1 -1
- package/dist/i18n/en.d.cts +19 -6
- package/dist/i18n/en.d.mts +19 -6
- package/dist/i18n/en.d.ts +19 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/o11y/parsers/hermes.cjs +1 -1
- package/dist/o11y/parsers/hermes.cjs.map +1 -1
- package/dist/o11y/prices.json +1 -1
- package/dist/o11y/record/families.cjs +12 -3
- package/dist/o11y/record/families.cjs.map +1 -1
- package/dist/o11y/record/families.d.cts +8 -8
- package/dist/o11y/record/families.d.mts +8 -8
- package/dist/o11y/record/families.d.ts +8 -8
- package/dist/o11y/record/family-projectors.d.cts +66 -18
- package/dist/o11y/record/family-projectors.d.mts +66 -18
- package/dist/o11y/record/family-projectors.d.ts +66 -18
- package/dist/o11y/record/family-writers.d.cts +11 -3
- package/dist/o11y/record/family-writers.d.mts +11 -3
- package/dist/o11y/record/family-writers.d.ts +11 -3
- package/dist/o11y/record/runner-producer.cjs +14 -4
- package/dist/o11y/record/runner-producer.cjs.map +1 -1
- package/dist/record/codec/core.d.cts +2 -2
- package/dist/record/codec/core.d.mts +2 -2
- package/dist/record/codec/core.d.ts +2 -2
- package/dist/record/family/catalog.d.cts +44 -12
- package/dist/record/family/catalog.d.mts +44 -12
- package/dist/record/family/catalog.d.ts +44 -12
- package/dist/record/family/index.js +128 -124
- package/dist/record/family/observability-v1.cjs +35 -0
- package/dist/record/family/observability-v1.cjs.map +1 -0
- package/dist/record/family/observability-v1.d.cts +3 -0
- package/dist/record/family/observability-v1.d.mts +3 -0
- package/dist/record/family/observability-v1.d.ts +3 -0
- package/dist/record/family/observability-v1.js +6 -0
- package/dist/record/family/observability-v1.js.map +1 -0
- package/dist/record/family/observability.cjs +58 -9
- package/dist/record/family/observability.cjs.map +1 -1
- package/dist/record/family/observability.d.cts +1014 -15
- package/dist/record/family/observability.d.mts +1014 -15
- package/dist/record/family/observability.d.ts +1014 -15
- package/dist/record/family/observability.js +22 -18
- package/dist/record/host/runtime.cjs +600 -31
- package/dist/record/host/runtime.cjs.map +1 -1
- package/dist/record/host/types.cjs.map +1 -1
- package/dist/record/host/types.d.cts +33 -9
- package/dist/record/host/types.d.mts +33 -9
- package/dist/record/host/types.d.ts +33 -9
- package/dist/record/maintenance/runtime.cjs +1 -2
- package/dist/record/maintenance/runtime.cjs.map +1 -1
- package/dist/record/model/core.cjs.map +1 -1
- package/dist/record/model/core.d.cts +1 -1
- package/dist/record/model/core.d.mts +1 -1
- package/dist/record/model/core.d.ts +1 -1
- package/dist/record/model/definition.d.cts +6 -6
- package/dist/record/model/definition.d.mts +6 -6
- package/dist/record/model/definition.d.ts +6 -6
- package/dist/record/model/identifiers.cjs +1 -1
- package/dist/record/model/identifiers.cjs.map +1 -1
- package/dist/record/model/identifiers.d.cts +1 -1
- package/dist/record/model/identifiers.d.mts +1 -1
- package/dist/record/model/identifiers.d.ts +1 -1
- package/dist/record/platform/node.cjs +159 -23
- package/dist/record/platform/node.cjs.map +1 -1
- package/dist/record/platform/services.cjs.map +1 -1
- package/dist/record/platform/services.d.cts +15 -2
- package/dist/record/platform/services.d.mts +15 -2
- package/dist/record/platform/services.d.ts +15 -2
- package/dist/record/reader/errors.cjs +37 -1
- package/dist/record/reader/errors.cjs.map +1 -1
- package/dist/record/reader/errors.d.cts +49 -1
- package/dist/record/reader/errors.d.mts +49 -1
- package/dist/record/reader/errors.d.ts +49 -1
- package/dist/record/reader/errors.js +22 -12
- package/dist/record/reader/format.cjs +76 -17
- package/dist/record/reader/format.cjs.map +1 -1
- package/dist/record/reader/format.d.cts +11 -4
- package/dist/record/reader/format.d.mts +11 -4
- package/dist/record/reader/format.d.ts +11 -4
- package/dist/record/reader/format.js +2 -0
- package/dist/record/reader/index.js +32 -18
- package/dist/record/reader/runtime.cjs +64 -0
- package/dist/record/reader/runtime.cjs.map +1 -1
- package/dist/record/reader/runtime.d.cts +15 -0
- package/dist/record/reader/runtime.d.mts +15 -0
- package/dist/record/reader/runtime.d.ts +15 -0
- package/dist/record/reader/runtime.js +2 -0
- package/dist/report/assets/styles.css +53 -29
- package/dist/report/built-in/analysis-values.cjs +21 -13
- package/dist/report/built-in/analysis-values.cjs.map +1 -1
- package/dist/report/built-in/analysis-values.d.cts +11 -22
- package/dist/report/built-in/analysis-values.d.mts +11 -22
- package/dist/report/built-in/analysis-values.d.ts +11 -22
- package/dist/report/built-in/analysis-values.js +4 -6
- package/dist/report/built-in/index.cjs +1 -3
- package/dist/report/built-in/index.cjs.map +1 -1
- package/dist/report/built-in/index.d.cts +1 -1
- package/dist/report/built-in/index.d.mts +1 -1
- package/dist/report/built-in/index.d.ts +1 -1
- package/dist/report/built-in/index.js +4 -8
- package/dist/report/built-in/index.mjs +4 -8
- package/dist/report/built-in/machine.cjs +0 -2
- package/dist/report/built-in/machine.cjs.map +1 -1
- package/dist/report/built-in/machine.d.cts +0 -2
- package/dist/report/built-in/machine.d.mts +0 -2
- package/dist/report/built-in/machine.d.ts +0 -2
- package/dist/report/built-in/result-components.cjs +49 -51
- package/dist/report/built-in/result-components.cjs.map +1 -1
- package/dist/report/built-in/result-components.d.cts +16 -17
- package/dist/report/built-in/result-components.d.mts +16 -17
- package/dist/report/built-in/result-components.d.ts +16 -17
- package/dist/report/built-in/result-components.js +0 -4
- package/dist/report/built-in/run-membership-overview.cjs +126 -17
- package/dist/report/built-in/run-membership-overview.cjs.map +1 -1
- package/dist/report/built-in/run-membership-overview.d.cts +14 -0
- package/dist/report/built-in/run-membership-overview.d.mts +14 -0
- package/dist/report/built-in/run-membership-overview.d.ts +14 -0
- package/dist/report/built-in/run-membership-overview.js +4 -2
- package/dist/report/built-in/standard.cjs +80 -45
- package/dist/report/built-in/standard.cjs.map +1 -1
- package/dist/report/built-in/standard.d.cts +19 -41
- package/dist/report/built-in/standard.d.mts +19 -41
- package/dist/report/built-in/standard.d.ts +19 -41
- package/dist/report/built-in/standard.js +6 -6
- package/dist/report/components/attempt-detail/compute.cjs +78 -2
- package/dist/report/components/attempt-detail/compute.cjs.map +1 -1
- package/dist/report/components/attempt-detail/compute.d.cts +1 -1
- package/dist/report/components/attempt-detail/compute.d.mts +1 -1
- package/dist/report/components/attempt-detail/compute.d.ts +1 -1
- package/dist/report/components/attempt-detail/content.cjs +1 -1
- package/dist/report/components/attempt-detail/content.cjs.map +1 -1
- package/dist/report/components/entity-lists/compute.cjs +42 -5
- package/dist/report/components/entity-lists/compute.cjs.map +1 -1
- package/dist/report/components/entity-lists/compute.d.cts +10 -8
- package/dist/report/components/entity-lists/compute.d.mts +10 -8
- package/dist/report/components/entity-lists/compute.d.ts +10 -8
- package/dist/report/components/entity-lists/content.cjs +31 -6
- package/dist/report/components/entity-lists/content.cjs.map +1 -1
- package/dist/report/components/entity-lists/index.cjs +9 -4
- package/dist/report/components/entity-lists/index.cjs.map +1 -1
- package/dist/report/components/entity-lists/index.d.cts +4 -7
- package/dist/report/components/entity-lists/index.d.mts +4 -7
- package/dist/report/components/entity-lists/index.d.ts +4 -7
- package/dist/report/components/summaries/compute.cjs +8 -1
- package/dist/report/components/summaries/compute.cjs.map +1 -1
- package/dist/report/components/summaries/compute.d.cts +9 -1
- package/dist/report/components/summaries/compute.d.mts +9 -1
- package/dist/report/components/summaries/compute.d.ts +9 -1
- package/dist/report/components/summaries/index.cjs +48 -4
- package/dist/report/components/summaries/index.cjs.map +1 -1
- package/dist/report/components/summaries/index.d.cts +7 -4
- package/dist/report/components/summaries/index.d.mts +7 -4
- package/dist/report/components/summaries/index.d.ts +7 -4
- package/dist/report/definition/cell.cjs +3 -0
- package/dist/report/definition/cell.cjs.map +1 -1
- package/dist/report/definition/cell.d.cts +2 -0
- package/dist/report/definition/cell.d.mts +2 -0
- package/dist/report/definition/cell.d.ts +2 -0
- package/dist/report/definition/primitives/chart.cjs +8 -5
- package/dist/report/definition/primitives/chart.cjs.map +1 -1
- package/dist/report/definition/primitives/points-dataset.cjs +1 -0
- package/dist/report/definition/primitives/points-dataset.cjs.map +1 -1
- package/dist/report/definition/primitives.cjs +15 -2
- package/dist/report/definition/primitives.cjs.map +1 -1
- package/dist/report/definition/report.cjs +27 -3
- package/dist/report/definition/report.cjs.map +1 -1
- package/dist/report/definition/report.d.cts +8 -0
- package/dist/report/definition/report.d.mts +8 -0
- package/dist/report/definition/report.d.ts +8 -0
- package/dist/report/execution/machine.cjs +30 -14
- package/dist/report/execution/machine.cjs.map +1 -1
- package/dist/report/execution/machine.d.cts +20 -10
- package/dist/report/execution/machine.d.mts +20 -10
- package/dist/report/execution/machine.d.ts +20 -10
- package/dist/report/execution/machine.js +6 -6
- package/dist/report/host/execute.cjs +25 -16
- package/dist/report/host/execute.cjs.map +1 -1
- package/dist/report/host/execute.d.cts +4 -0
- package/dist/report/host/execute.d.mts +4 -0
- package/dist/report/host/execute.d.ts +4 -0
- package/dist/report/host/from-record.cjs +22 -5
- package/dist/report/host/from-record.cjs.map +1 -1
- package/dist/report/host/machine.cjs +53 -11
- package/dist/report/host/machine.cjs.map +1 -1
- package/dist/report/host/site-runtime.cjs +9 -8
- package/dist/report/host/site-runtime.cjs.map +1 -1
- package/dist/report/host/site-runtime.d.cts +1 -1
- package/dist/report/host/site-runtime.d.mts +1 -1
- package/dist/report/host/site-runtime.d.ts +1 -1
- package/dist/report/host/static.cjs +56 -9
- package/dist/report/host/static.cjs.map +1 -1
- package/dist/report/index.cjs.map +1 -1
- package/dist/report/index.d.cts +1 -1
- package/dist/report/index.d.mts +1 -1
- package/dist/report/index.d.ts +1 -1
- package/dist/report/model/dataset.cjs +7 -2
- package/dist/report/model/dataset.cjs.map +1 -1
- package/dist/report/model/locale.cjs +2 -0
- package/dist/report/model/locale.cjs.map +1 -1
- package/dist/report/model/locale.d.cts +1 -0
- package/dist/report/model/locale.d.mts +1 -0
- package/dist/report/model/locale.d.ts +1 -0
- package/dist/report/model/metrics.cjs +3 -1
- package/dist/report/model/metrics.cjs.map +1 -1
- package/dist/report/model/pricing.cjs +16 -11
- package/dist/report/model/pricing.cjs.map +1 -1
- package/dist/report/react/styles.css +53 -29
- package/dist/runner/adoption.cjs +1 -0
- package/dist/runner/adoption.cjs.map +1 -1
- package/dist/runner/attempt.cjs +44 -5
- package/dist/runner/attempt.cjs.map +1 -1
- package/dist/runner/attempt.d.cts +13 -1
- package/dist/runner/attempt.d.mts +13 -1
- package/dist/runner/attempt.d.ts +13 -1
- package/dist/runner/config-identity.cjs +10 -2
- package/dist/runner/config-identity.cjs.map +1 -1
- package/dist/runner/config-identity.d.cts +4 -2
- package/dist/runner/config-identity.d.mts +4 -2
- package/dist/runner/config-identity.d.ts +4 -2
- package/dist/runner/feedback/human.cjs +298 -59
- package/dist/runner/feedback/human.cjs.map +1 -1
- package/dist/runner/feedback/json.cjs +14 -6
- package/dist/runner/feedback/json.cjs.map +1 -1
- package/dist/runner/feedback/json.d.cts +3 -2
- package/dist/runner/feedback/json.d.mts +3 -2
- package/dist/runner/feedback/json.d.ts +3 -2
- package/dist/runner/feedback/reducer.cjs +2 -0
- package/dist/runner/feedback/reducer.cjs.map +1 -1
- package/dist/runner/judge-config.cjs +1 -1
- package/dist/runner/judge-config.cjs.map +1 -1
- package/dist/runner/ledger.cjs +124 -12
- package/dist/runner/ledger.cjs.map +1 -1
- package/dist/runner/project-current.cjs +13 -5
- package/dist/runner/project-current.cjs.map +1 -1
- package/dist/runner/run.cjs +564 -256
- package/dist/runner/run.cjs.map +1 -1
- package/dist/runner/sandbox-pool.cjs +161 -30
- package/dist/runner/sandbox-pool.cjs.map +1 -1
- package/dist/runner/sandbox-pool.d.cts +34 -2
- package/dist/runner/sandbox-pool.d.mts +34 -2
- package/dist/runner/sandbox-pool.d.ts +34 -2
- package/dist/runner/shared-state-lease.cjs +803 -0
- package/dist/runner/shared-state-lease.cjs.map +1 -0
- package/dist/runner/shared-state-lease.d.cts +121 -0
- package/dist/runner/shared-state-lease.d.mts +121 -0
- package/dist/runner/shared-state-lease.d.ts +121 -0
- package/dist/runner/shared-state-lease.js +24 -0
- package/dist/runner/shared-state-lease.js.map +1 -0
- package/dist/runner/teardown-registry.cjs +97 -34
- package/dist/runner/teardown-registry.cjs.map +1 -1
- package/dist/runner/teardown-registry.d.cts +27 -1
- package/dist/runner/teardown-registry.d.mts +27 -1
- package/dist/runner/teardown-registry.d.ts +27 -1
- package/dist/runner/teardown-registry.js +20 -16
- package/dist/runner/types.cjs.map +1 -1
- package/dist/runner/types.d.cts +31 -5
- package/dist/runner/types.d.mts +31 -5
- package/dist/runner/types.d.ts +31 -5
- package/dist/sample/analysis.cjs +249 -459
- package/dist/sample/analysis.cjs.map +1 -1
- package/dist/sample/capability.cjs +138 -7
- package/dist/sample/capability.cjs.map +1 -1
- package/dist/sample/capability.d.cts +3 -1
- package/dist/sample/capability.d.mts +3 -1
- package/dist/sample/capability.d.ts +3 -1
- package/dist/sample/capability.js +8 -6
- package/dist/sandbox/docker-agent-image.cjs +5 -1
- package/dist/sandbox/docker-agent-image.cjs.map +1 -1
- package/dist/sandbox/docker-agent-image.d.cts +2 -0
- package/dist/sandbox/docker-agent-image.d.mts +2 -0
- package/dist/sandbox/docker-agent-image.d.ts +2 -0
- package/dist/sandbox/docker-agent-image.js +14 -10
- package/dist/sandbox/docker-profile/schema.cjs +283 -534
- package/dist/sandbox/docker-profile/schema.cjs.map +1 -1
- package/dist/sandbox/docker-profile/schema.d.cts +10 -27
- package/dist/sandbox/docker-profile/schema.d.mts +10 -27
- package/dist/sandbox/docker-profile/schema.d.ts +10 -27
- package/dist/sandbox/e2b-agent-template.cjs +5 -2
- package/dist/sandbox/e2b-agent-template.cjs.map +1 -1
- package/dist/sandbox/index.cjs +4 -2
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.d.cts +1 -1
- package/dist/sandbox/index.d.mts +1 -1
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +120 -116
- package/dist/sandbox/index.mjs +120 -116
- package/dist/sandbox/keep-registry.cjs +28 -66
- package/dist/sandbox/keep-registry.cjs.map +1 -1
- package/dist/sandbox/types.cjs.map +1 -1
- package/dist/sandbox/types.d.cts +1 -1
- package/dist/sandbox/types.d.mts +1 -1
- package/dist/sandbox/types.d.ts +1 -1
- package/dist/shared/aggregate.cjs +16 -6
- package/dist/shared/aggregate.cjs.map +1 -1
- package/dist/shared/aggregate.d.cts +12 -4
- package/dist/shared/aggregate.d.mts +12 -4
- package/dist/shared/aggregate.d.ts +12 -4
- package/dist/shared/turn-label.cjs +20 -2
- package/dist/shared/turn-label.cjs.map +1 -1
- package/dist/shared/turn-label.d.cts +2 -0
- package/dist/shared/turn-label.d.mts +2 -0
- package/dist/shared/turn-label.d.ts +2 -0
- package/dist/shared/turn-label.js +4 -2
- package/dist/vendor/remark/remark-gfm.cjs +7 -7
- package/dist/vendor/remark/remark-gfm.cjs.map +1 -1
- package/dist/vendor/remark/remark-parse.cjs +12 -12
- package/dist/vendor/remark/remark-parse.cjs.map +1 -1
- package/dist/vendor/remark/remark.cjs +13 -13
- package/dist/vendor/remark/remark.cjs.map +1 -1
- package/dist/view/server.cjs +6 -0
- package/dist/view/server.cjs.map +1 -1
- package/docs-site/images/hitl-handshake-zh.svg +3 -3
- package/docs-site/zh/examples/ai-agent-application.mdx +1 -1
- package/docs-site/zh/examples/coding-agent-extensions.mdx +1 -1
- package/docs-site/zh/examples/integrations/ai-sdk-v7.mdx +4 -3
- package/docs-site/zh/examples/integrations/claude-sdk.mdx +3 -3
- package/docs-site/zh/examples/integrations/codex-sdk.mdx +5 -5
- package/docs-site/zh/examples/integrations/langgraph.mdx +4 -4
- package/docs-site/zh/examples/integrations/pi-sdk.mdx +5 -5
- package/docs-site/zh/explanation/adapter.mdx +5 -5
- package/docs-site/zh/explanation/assert.mdx +7 -7
- package/docs-site/zh/explanation/drive.mdx +4 -2
- package/docs-site/zh/explanation/evals.mdx +10 -8
- package/docs-site/zh/explanation/experiment.mdx +2 -2
- package/docs-site/zh/explanation/hitl.mdx +9 -9
- package/docs-site/zh/explanation/judge.mdx +5 -5
- package/docs-site/zh/explanation/overview.mdx +3 -3
- package/docs-site/zh/explanation/runner.mdx +1 -1
- package/docs-site/zh/index.mdx +3 -3
- package/docs-site/zh/reference/builtin-agents.mdx +13 -13
- package/docs-site/zh/reference/capabilities.mdx +1 -1
- package/docs-site/zh/reference/cli.mdx +18 -12
- package/docs-site/zh/reference/define-agent.mdx +130 -5
- package/docs-site/zh/reference/define-config.mdx +2 -2
- package/docs-site/zh/reference/define-eval.mdx +4 -4
- package/docs-site/zh/reference/events.mdx +11 -11
- package/docs-site/zh/reference/official-adapters.mdx +6 -6
- package/docs-site/zh/reference/results-data.mdx +6 -0
- package/docs-site/zh/troubleshooting/debugging.mdx +1 -1
- package/docs-site/zh/troubleshooting/recover-after-kill.mdx +37 -5
- package/docs-site/zh/tutorials/accept-results.mdx +72 -0
- package/docs-site/zh/tutorials/agent-onboarding.mdx +6 -6
- package/docs-site/zh/tutorials/authoring.mdx +9 -13
- package/docs-site/zh/tutorials/ci-integration.mdx +6 -6
- package/docs-site/zh/tutorials/compare-runs.mdx +61 -0
- package/docs-site/zh/tutorials/concurrency.mdx +13 -12
- package/docs-site/zh/tutorials/configuration.mdx +4 -6
- package/docs-site/zh/tutorials/connect-your-agent.mdx +1 -1
- package/docs-site/zh/tutorials/control-run-cost.mdx +58 -0
- package/docs-site/zh/tutorials/criteria-files.mdx +2 -2
- package/docs-site/zh/tutorials/custom-reports.mdx +2 -2
- package/docs-site/zh/tutorials/debug-lifecycle-plan.mdx +46 -0
- package/docs-site/zh/tutorials/docker-in-docker.mdx +52 -43
- package/docs-site/zh/tutorials/eval-groups.mdx +6 -6
- package/docs-site/zh/tutorials/evaluation-kinds.mdx +3 -3
- package/docs-site/zh/tutorials/experiments.mdx +2 -3
- package/docs-site/zh/tutorials/handle-execution-failures.mdx +18 -10
- package/docs-site/zh/tutorials/install-custom-sandbox-agent.mdx +16 -8
- package/docs-site/zh/tutorials/nixos-managed-dind.mdx +160 -0
- package/docs-site/zh/tutorials/plugins.mdx +14 -0
- package/docs-site/zh/tutorials/rerun-and-cache.mdx +4 -2
- package/docs-site/zh/tutorials/sandbox-agent.mdx +17 -11
- package/docs-site/zh/tutorials/sandbox-providers.mdx +17 -13
- package/docs-site/zh/tutorials/sandbox-reuse.mdx +12 -19
- package/docs-site/zh/tutorials/select-and-preview.mdx +65 -0
- package/docs-site/zh/tutorials/verify-judge.mdx +78 -0
- package/docs-site/zh/tutorials/viewing-results.mdx +38 -1
- package/docs-site/zh/tutorials/write-experiment.mdx +7 -5
- package/docs-site/zh/tutorials/write-send.mdx +9 -8
- package/package.json +9 -5
- package/dist/report/built-in/overview.cjs +0 -44
- package/dist/report/built-in/overview.cjs.map +0 -1
- package/dist/report/built-in/overview.d.cts +0 -6
- package/dist/report/built-in/overview.d.mts +0 -6
- package/dist/report/built-in/overview.d.ts +0 -6
- package/dist/report/built-in/overview.js +0 -9
- package/dist/report/built-in/overview.js.map +0 -1
- package/dist/runner/gate-lease.cjs +0 -283
- package/dist/runner/gate-lease.cjs.map +0 -1
- package/dist/runner/gate-lease.d.cts +0 -62
- package/dist/runner/gate-lease.d.mts +0 -62
- package/dist/runner/gate-lease.d.ts +0 -62
- package/dist/runner/gate-lease.js +0 -22
- package/dist/runner/gate-lease.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-state-lease.js","sourceRoot":"","sources":["shared-state-lease.ts"],"names":[],"mappings":";;;AAyJA,wDAEC;AA6VD,gEASC;AAOD,4FAOC;AAqDD,kEAiDC;AACD,oEAIC;AAkFD,sEAqEC;AAgDD,wFA8CC;AASD,8FA6BC;AAr5BD,2EAA2E;AAC3E,0EAA0E;AAC1E,4EAA4E;AAC5E,qEAAqE;AACrE,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,2DAA8C;AAC9C,6CAAyC;AACzC,+CAA6F;AAC7F,yCAAiC;AACjC,mCAAwD;AACxD,uEAA4H;AAC5H,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAChE,MAAM,8BAA8B,GAAG,qCAAqC,CAAC;AAC7E,MAAM,6BAA6B,GAAG,oCAAoC,CAAC;AAC3E,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAC7C,MAAM,sBAAsB,GAAG,OAAO,CAAC;AACvC,MAAM,gBAAgB,G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AAM,KAAK,SAAS,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,sCAAsC,EAAE,qBAAqB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC,CAAC;QAC7P,CAAC;QACD,OAAO,4BAA4B,EAAE,CAAC,IAAI,CAAC,eAAM,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;YAC1E,IAAI,CAAC,uCAAuC,CAAC,OAAO,CAAC,aAAc,EAAE,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,EAAE,CAAC;gBACrG,OAAO,eAAM,CAAC,IAAI,CAAC,IAAI,qBAAqB,CAAC,sCAAsC,EAAE,qBAAqB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC,CAAC;YACvL,CAAC;YACD,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,GAAG,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;YAC3F,OAAO,gCAAgC,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,eAAM,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,eAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAChL,CAAC,CAAC,CAAC,CAAC;IACR,CAAC,CAAC,CAAC,CAAC,CAAC;IACL,OAAO,QAAQ,EAAE,CAAC;AACtB,CAAC","sourcesContent":["// Shared-state leases protect an author's external mutable state. They are\n// deliberately *not* case locks: a lease never expires and is never taken\n// over by a waiter. A crashed or failed cleanup path stays visible until an\n// operator performs the explicit, owner-token-checked recovery flow.\n//\n// The durable authority is an append-only generation chain. A transition may\n// only publish generation N + 1 after observing exact generation N, and uses\n// a same-directory hard-link to occupy that fixed N + 1 name. Consequently a\n// stale actor cannot delete, replace, or otherwise reach a newer generation.\nimport { execFile } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { link, mkdir, open, readFile, readdir, rm, type FileHandle } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { Clock, Deferred, Effect, Fiber } from \"effect\";\nimport { fsyncDirEffect, readEntryFileEffect, slugHashEntryId, writeEntryFileEffect, } from \"../shared/entry-file-store.ts\";\nconst SHARED_STATE_LEASE_NAMESPACE = \"niceeval/shared-state/v3\";\nconst SHARED_STATE_GENERATION_FORMAT = \"niceeval.shared-state-generation/v1\";\nconst SHARED_STATE_HEARTBEAT_FORMAT = \"niceeval.shared-state-heartbeat/v1\";\nconst GENERATION_FILE_PREFIX = \"generation-\";\nconst GENERATION_FILE_SUFFIX = \".json\";\nconst GENERATION_WIDTH = 20;\nexport const SHARED_STATE_LEASE_HEARTBEAT_INTERVAL_MS = 10000;\nexport type SharedStateLeaseStatus = \"active\" | \"recovering\";\n/** The process currently running an explicit recovery hook. */\nexport interface SharedStateRecoveryActor {\n readonly pid: number;\n readonly host: string;\n readonly processIdentity: string;\n readonly startedAt: string;\n}\n/** Durable, human-readable ownership evidence. The owner token is immutable. */\nexport interface SharedStateLeaseRecord {\n readonly key: string;\n readonly experimentId: string;\n readonly ownerToken: string;\n readonly pid: number;\n readonly host: string;\n readonly processIdentity: string;\n readonly acquiredAt: string;\n /**\n * Public diagnostic heartbeat time. The immutable generation starts it at\n * acquisition; public reads may overlay a matching non-authoritative\n * sidecar. Heartbeats never grant authority.\n */\n readonly heartbeatAt: string;\n readonly status: SharedStateLeaseStatus;\n /** Immutable transition generation which made this record authoritative. */\n readonly generation: number;\n /** The exact prior authoritative generation (zero for a fresh chain). */\n readonly parentGeneration: number;\n /** Present only while an explicit CLI recovery is holding the lease closed. */\n readonly recoveryId?: string;\n readonly recoveryActor?: SharedStateRecoveryActor;\n}\nexport interface SharedStateLeaseIdentity {\n readonly experimentId: string;\n readonly pid: number;\n readonly host: string;\n readonly processIdentity: string;\n}\nexport class SharedStateLeaseError extends Error {\n constructor(readonly code: \"shared-state-lease-invalid\" | \"shared-state-lease-owner-mismatch\" | \"shared-state-lease-missing\" | \"shared-state-owner-still-live\" | \"shared-state-process-identity-unavailable\" | \"shared-state-recovery-confirmation-required\" | \"shared-state-recovery-state-mismatch\" | \"shared-state-recovery-in-progress\" | \"shared-state-recovery-identity-unavailable\", message: string) {\n super(message);\n this.name = \"SharedStateLeaseError\";\n }\n}\nexport interface SharedStateLeaseEffectClaim {\n readonly ownerToken: string;\n /** Releases only this exact owner generation. It never deletes a newer holder. */\n readonly release: Effect.Effect<void, SharedStateLeaseError | unknown>;\n /**\n * Stops this process's diagnostic heartbeat without mutating the durable\n * lease. Cleanup failures use this path: the record must survive for an\n * explicit recovery, but it must not keep the finished CLI process alive.\n */\n readonly abandon: Effect.Effect<void>;\n}\nexport interface AcquireSharedStateLeaseEffectResult {\n readonly claim: SharedStateLeaseEffectClaim;\n}\n/** A recovery either owns a durable recovery marker or found a completed release. */\nexport type ExplicitSharedStateRecovery = {\n readonly _tag: \"Claimed\";\n readonly record: SharedStateLeaseRecord;\n readonly recoveryId: string;\n} | {\n readonly _tag: \"AlreadyReleased\";\n readonly record: SharedStateLeaseRecord;\n};\ninterface SharedStateFreeGeneration {\n readonly kind: \"free\";\n readonly key: string;\n readonly generation: number;\n readonly parentGeneration: number;\n readonly releasedAt: string;\n /** The exact lease generation which was released. */\n readonly previous: SharedStateLeaseRecord;\n}\ntype SharedStateGeneration = {\n readonly kind: \"lease\";\n readonly record: SharedStateLeaseRecord;\n} | SharedStateFreeGeneration | {\n readonly kind: \"legacy\";\n readonly record: SharedStateLeaseRecord;\n};\ninterface SharedStateLedger {\n readonly dir: string;\n readonly latest: SharedStateGeneration | undefined;\n}\n/**\n * Non-authoritative, atomically replaced diagnostic heartbeat. Its filename\n * and payload are pinned to one immutable owner generation, so even a writer\n * that races a later release/recovery can never affect a newer holder.\n */\ninterface SharedStateLeaseHeartbeat {\n readonly format: typeof SHARED_STATE_HEARTBEAT_FORMAT;\n readonly key: string;\n readonly ownerToken: string;\n readonly generation: number;\n readonly parentGeneration: number;\n readonly heartbeatAt: string;\n}\nfunction errnoCode(cause: unknown): string | undefined {\n return typeof cause === \"object\" && cause !== null && \"code\" in cause && typeof cause.code === \"string\"\n ? cause.code\n : undefined;\n}\nfunction isPositiveInteger(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value > 0;\n}\nfunction isNonNegativeInteger(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0;\n}\nfunction isTimestamp(value: unknown): value is string {\n return typeof value === \"string\" && Number.isFinite(Date.parse(value));\n}\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0;\n}\nfunction recordOf(value: unknown): globalThis.Record<string, unknown> | undefined {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? value as globalThis.Record<string, unknown>\n : undefined;\n}\nfunction nodeIo<A>(operation: (signal: AbortSignal) => Promise<A>): Effect.Effect<A, unknown> {\n return Effect.tryPromise({ try: operation, catch: (cause) => cause });\n}\nfunction nodeSync<A>(operation: () => A): Effect.Effect<A, unknown> {\n return Effect.try({ try: operation, catch: (cause) => cause });\n}\nfunction withOpenFile<A>(path: string, flags: string, use: (handle: FileHandle) => Effect.Effect<A, unknown>): Effect.Effect<A, unknown> {\n return Effect.scoped(Effect.acquireRelease(nodeIo(() => open(path, flags)), (handle) => nodeIo(() => handle.close()).pipe(Effect.orDie)).pipe(Effect.flatMap(use)));\n}\nexport function sharedStateLeasesDirOf(niceevalRoot: string): string {\n return join(niceevalRoot, \"shared-state-leases\");\n}\nfunction sharedStateLeaseEntryId(key: string): string {\n return slugHashEntryId(key, [SHARED_STATE_LEASE_NAMESPACE, key]);\n}\nfunction sharedStateLeaseGenerationDirOf(niceevalRoot: string, key: string): string {\n return join(sharedStateLeasesDirOf(niceevalRoot), `${sharedStateLeaseEntryId(key)}.generations`);\n}\nfunction sharedStateLeaseHeartbeatDirOf(generationDir: string): string {\n return join(generationDir, \"heartbeats\");\n}\nfunction sharedStateLeaseHeartbeatEntryId(record: SharedStateLeaseRecord): string {\n return slugHashEntryId(`generation-${record.generation}`, [\"niceeval/shared-state-heartbeat/v1\", record.key, record.ownerToken, String(record.generation)]);\n}\n/** v2 used a mutable flat entry. We only read it to fail closed or explicitly recover it. */\nfunction legacySharedStateLeasePath(niceevalRoot: string, key: string): string {\n return join(sharedStateLeasesDirOf(niceevalRoot), `${slugHashEntryId(key, [\"niceeval/shared-state/v2\", key])}.json`);\n}\nfunction generationFileName(generation: number): string {\n return `${GENERATION_FILE_PREFIX}${String(generation).padStart(GENERATION_WIDTH, \"0\")}${GENERATION_FILE_SUFFIX}`;\n}\nfunction generationFromFileName(name: string): number | undefined {\n const match = /^generation-(\\d+)\\.json$/u.exec(name);\n if (match === null)\n return undefined;\n const generation = Number(match[1]);\n return isPositiveInteger(generation) && name === generationFileName(generation) ? generation : undefined;\n}\nfunction decodeRecoveryActor(value: unknown): SharedStateRecoveryActor | undefined {\n const actor = recordOf(value);\n if (actor === undefined ||\n !isPositiveInteger(actor.pid) ||\n !isNonEmptyString(actor.host) ||\n !isNonEmptyString(actor.processIdentity) ||\n !isTimestamp(actor.startedAt)) {\n return undefined;\n }\n return Object.freeze({\n pid: actor.pid,\n host: actor.host,\n processIdentity: actor.processIdentity,\n startedAt: actor.startedAt,\n });\n}\nfunction decodeSharedStateLeaseRecord(key: string, value: unknown, opts: {\n readonly legacy?: boolean;\n} = {}): SharedStateLeaseRecord | undefined {\n const record = recordOf(value);\n if (record === undefined)\n return undefined;\n const recoveryActor = record.recoveryActor === undefined ? undefined : decodeRecoveryActor(record.recoveryActor);\n const recovering = record.status === \"recovering\";\n const generation = opts.legacy ? 0 : record.generation;\n const parentGeneration = opts.legacy ? 0 : record.parentGeneration;\n if (record.key !== key ||\n !isNonEmptyString(record.experimentId) ||\n !isNonEmptyString(record.ownerToken) ||\n !isPositiveInteger(record.pid) ||\n !isNonEmptyString(record.host) ||\n !isNonEmptyString(record.processIdentity) ||\n !isTimestamp(record.acquiredAt) ||\n !isTimestamp(record.heartbeatAt) ||\n (record.status !== \"active\" && !recovering) ||\n (!opts.legacy && (!isPositiveInteger(generation) || !isNonNegativeInteger(parentGeneration) || parentGeneration >= generation)) ||\n (recovering && (!isNonEmptyString(record.recoveryId) || recoveryActor === undefined)) ||\n (!recovering && (record.recoveryId !== undefined || record.recoveryActor !== undefined))) {\n return undefined;\n }\n return Object.freeze({\n key,\n experimentId: record.experimentId,\n ownerToken: record.ownerToken,\n pid: record.pid,\n host: record.host,\n processIdentity: record.processIdentity,\n acquiredAt: record.acquiredAt,\n heartbeatAt: record.heartbeatAt,\n status: record.status as SharedStateLeaseStatus,\n generation: generation as number,\n parentGeneration: parentGeneration as number,\n ...(recovering ? { recoveryId: record.recoveryId as string, recoveryActor: recoveryActor! } : {}),\n });\n}\nfunction decodeSharedStateLeaseHeartbeat(record: SharedStateLeaseRecord, value: unknown): SharedStateLeaseHeartbeat | undefined {\n const heartbeat = recordOf(value);\n if (heartbeat === undefined ||\n heartbeat.format !== SHARED_STATE_HEARTBEAT_FORMAT ||\n heartbeat.key !== record.key ||\n heartbeat.ownerToken !== record.ownerToken ||\n heartbeat.generation !== record.generation ||\n heartbeat.parentGeneration !== record.parentGeneration ||\n !isTimestamp(heartbeat.heartbeatAt) ||\n Date.parse(heartbeat.heartbeatAt) < Date.parse(record.acquiredAt)) {\n return undefined;\n }\n return Object.freeze({\n format: SHARED_STATE_HEARTBEAT_FORMAT,\n key: record.key,\n ownerToken: record.ownerToken,\n generation: record.generation,\n parentGeneration: record.parentGeneration,\n heartbeatAt: heartbeat.heartbeatAt,\n });\n}\n/**\n * A heartbeat is diagnostic only: unreadable, missing, stale, or malformed\n * sidecars leave the immutable generation record unchanged. Matching all of\n * key/token/generation/parent makes an old owner's sidecar inapplicable after\n * any release, recovery, or later acquisition.\n */\nfunction readDiagnosticHeartbeatEffect(generationDir: string, record: SharedStateLeaseRecord): Effect.Effect<SharedStateLeaseRecord, never> {\n return readEntryFileEffect(sharedStateLeaseHeartbeatDirOf(generationDir), sharedStateLeaseHeartbeatEntryId(record), (value) => decodeSharedStateLeaseHeartbeat(record, value)).pipe(Effect.map((heartbeat) => heartbeat === undefined\n ? record\n : Object.freeze({ ...record, heartbeatAt: heartbeat.heartbeatAt })), Effect.catchAll(() => Effect.succeed(record)));\n}\nfunction writeDiagnosticHeartbeatEffect(generationDir: string, record: SharedStateLeaseRecord, heartbeatAt: string): Effect.Effect<void, unknown> {\n const heartbeat: SharedStateLeaseHeartbeat = Object.freeze({\n format: SHARED_STATE_HEARTBEAT_FORMAT,\n key: record.key,\n ownerToken: record.ownerToken,\n generation: record.generation,\n parentGeneration: record.parentGeneration,\n heartbeatAt,\n });\n return writeEntryFileEffect(sharedStateLeaseHeartbeatDirOf(generationDir), sharedStateLeaseHeartbeatEntryId(record), heartbeat);\n}\nfunction decodeGeneration(key: string, value: unknown): SharedStateGeneration | undefined {\n const generation = recordOf(value);\n if (generation === undefined || generation.format !== SHARED_STATE_GENERATION_FORMAT)\n return undefined;\n if (generation.kind === \"lease\") {\n const record = decodeSharedStateLeaseRecord(key, generation);\n return record === undefined ? undefined : Object.freeze({ kind: \"lease\" as const, record });\n }\n if (generation.kind !== \"free\")\n return undefined;\n const previous = decodeSharedStateLeaseRecord(key, generation.previous);\n if (previous === undefined ||\n generation.key !== key ||\n !isPositiveInteger(generation.generation) ||\n !isNonNegativeInteger(generation.parentGeneration) ||\n generation.parentGeneration >= generation.generation ||\n generation.parentGeneration !== previous.generation ||\n !isTimestamp(generation.releasedAt)) {\n return undefined;\n }\n return Object.freeze({\n kind: \"free\" as const,\n key,\n generation: generation.generation,\n parentGeneration: generation.parentGeneration,\n releasedAt: generation.releasedAt,\n previous,\n });\n}\nfunction durableLeaseGeneration(record: SharedStateLeaseRecord): globalThis.Record<string, unknown> {\n return { format: SHARED_STATE_GENERATION_FORMAT, kind: \"lease\", ...record };\n}\nfunction durableFreeGeneration(record: SharedStateFreeGeneration): globalThis.Record<string, unknown> {\n return {\n format: SHARED_STATE_GENERATION_FORMAT,\n kind: \"free\",\n key: record.key,\n generation: record.generation,\n parentGeneration: record.parentGeneration,\n releasedAt: record.releasedAt,\n previous: record.previous,\n };\n}\nfunction generationNumber(generation: SharedStateGeneration | undefined): number {\n if (generation === undefined)\n return 0;\n return generation.kind === \"free\" ? generation.generation : generation.record.generation;\n}\nfunction leaseRecordOf(generation: SharedStateGeneration | undefined): SharedStateLeaseRecord | undefined {\n return generation?.kind === \"lease\" || generation?.kind === \"legacy\" ? generation.record : undefined;\n}\nfunction sameRecoveryActor(left: SharedStateRecoveryActor, right: SharedStateRecoveryActor): boolean {\n return left.pid === right.pid &&\n left.host === right.host &&\n left.processIdentity === right.processIdentity &&\n left.startedAt === right.startedAt;\n}\nfunction sameLeaseRecord(left: SharedStateLeaseRecord, right: SharedStateLeaseRecord): boolean {\n return left.key === right.key &&\n left.experimentId === right.experimentId &&\n left.ownerToken === right.ownerToken &&\n left.pid === right.pid &&\n left.host === right.host &&\n left.processIdentity === right.processIdentity &&\n left.acquiredAt === right.acquiredAt &&\n left.heartbeatAt === right.heartbeatAt &&\n left.status === right.status &&\n left.generation === right.generation &&\n left.parentGeneration === right.parentGeneration &&\n left.recoveryId === right.recoveryId &&\n (left.recoveryActor === undefined\n ? right.recoveryActor === undefined\n : right.recoveryActor !== undefined && sameRecoveryActor(left.recoveryActor, right.recoveryActor));\n}\n/** The immutable holder evidence must survive a recovery-to-recovery transition. */\nfunction sameLeaseOwnerEvidence(left: SharedStateLeaseRecord, right: SharedStateLeaseRecord): boolean {\n return left.key === right.key &&\n left.experimentId === right.experimentId &&\n left.ownerToken === right.ownerToken &&\n left.pid === right.pid &&\n left.host === right.host &&\n left.processIdentity === right.processIdentity &&\n left.acquiredAt === right.acquiredAt &&\n left.heartbeatAt === right.heartbeatAt;\n}\nfunction legalFirstGeneration(first: SharedStateGeneration, legacy: SharedStateLeaseRecord | undefined): boolean {\n if (first.kind !== \"lease\")\n return false;\n if (first.record.status === \"active\")\n return legacy === undefined;\n // The only allowed v2 migration is explicit recovery: legacy has no v3\n // transition slot, so it becomes immutable recovering generation 1.\n return legacy !== undefined && sameLeaseOwnerEvidence(first.record, legacy);\n}\nfunction legalGenerationTransition(previous: SharedStateGeneration, next: SharedStateGeneration): boolean {\n if (previous.kind === \"free\") {\n // Only a normal acquisition may follow a released generation.\n return next.kind === \"lease\" && next.record.status === \"active\";\n }\n const previousRecord = previous.record;\n if (next.kind === \"free\") {\n // A free record is a compare-owner release, not a newly invented history.\n return sameLeaseRecord(next.previous, previousRecord);\n }\n // An active holder cannot be replaced by another active holder. The sole\n // lease-to-lease transition is explicit recovery, retaining the original\n // owner evidence while assigning a new recovery actor/id.\n if (next.record.status !== \"recovering\" || !sameLeaseOwnerEvidence(next.record, previousRecord))\n return false;\n if (previousRecord.status !== \"recovering\")\n return true;\n // Recovering -> recovering is a new, separately identified recovery after\n // the prior actor stopped. Reusing either identity would make a stale actor\n // indistinguishable from the new operation.\n return next.record.recoveryId !== previousRecord.recoveryId &&\n next.record.recoveryActor !== undefined &&\n previousRecord.recoveryActor !== undefined &&\n !sameRecoveryActor(next.record.recoveryActor, previousRecord.recoveryActor);\n}\nfunction validateGenerationTransitions(key: string, entries: readonly {\n readonly generation: number;\n readonly state: SharedStateGeneration;\n}[], legacy: SharedStateLeaseRecord | undefined): SharedStateLeaseError | undefined {\n let previousGeneration = 0;\n let previous: SharedStateGeneration | undefined;\n for (const entry of entries) {\n const stateGeneration = generationNumber(entry.state);\n const parentGeneration = entry.state.kind === \"free\"\n ? entry.state.parentGeneration\n : entry.state.record.parentGeneration;\n if (entry.generation !== previousGeneration + 1 || stateGeneration !== entry.generation || parentGeneration !== previousGeneration) {\n return invalidLeaseError(key, \"generations are not a contiguous exact-parent chain\");\n }\n if (previous === undefined) {\n if (!legalFirstGeneration(entry.state, legacy)) {\n return invalidLeaseError(key, \"generation 1 must be an active fresh lease or a recovery of the exact v2 legacy owner\");\n }\n }\n else if (!legalGenerationTransition(previous, entry.state)) {\n return invalidLeaseError(key, `generation ${entry.generation} is not a legal transition from generation ${previousGeneration}`);\n }\n previous = entry.state;\n previousGeneration = entry.generation;\n }\n return undefined;\n}\nfunction invalidLeaseError(key: string, message: string): SharedStateLeaseError {\n return new SharedStateLeaseError(\"shared-state-lease-invalid\", `sharedState generation chain for ${JSON.stringify(key)} is invalid: ${message}. Recovery fails closed.`);\n}\nfunction readLegacySharedStateLeaseEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLeaseRecord | undefined, SharedStateLeaseError | unknown> {\n return nodeIo(() => readFile(legacySharedStateLeasePath(niceevalRoot, key), \"utf8\")).pipe(Effect.flatMap((raw) => nodeSync(() => JSON.parse(raw))), Effect.flatMap((value) => {\n const record = decodeSharedStateLeaseRecord(key, value, { legacy: true });\n return record === undefined\n ? Effect.fail(invalidLeaseError(key, \"the legacy mutable record cannot be decoded\"))\n : Effect.succeed(record);\n }), Effect.catchAll((cause) => errnoCode(cause) === \"ENOENT\" ? Effect.succeed(undefined) : Effect.fail(cause)));\n}\n/**\n * Read a contiguous immutable generation chain. Proposal files are ignored:\n * they are not authoritative until the hard-link has occupied a generation\n * filename. A malformed committed filename or record is an explicit fail\n * closed condition, never an opportunity to silently start a new holder.\n */\nfunction readSharedStateLedgerEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLedger, SharedStateLeaseError | unknown> {\n const dir = sharedStateLeaseGenerationDirOf(niceevalRoot, key);\n return nodeIo(() => readdir(dir)).pipe(Effect.catchAll((cause) => errnoCode(cause) === \"ENOENT\" ? Effect.succeed([] as string[]) : Effect.fail(cause)), Effect.flatMap((names): Effect.Effect<SharedStateLedger, SharedStateLeaseError | unknown> => {\n const generationNames = names.filter((name) => name.startsWith(GENERATION_FILE_PREFIX));\n const ordered: {\n name: string;\n generation: number;\n }[] = [];\n for (const name of generationNames) {\n const generation = generationFromFileName(name);\n if (generation === undefined) {\n return Effect.fail(invalidLeaseError(key, `committed filename ${JSON.stringify(name)} is not canonical`));\n }\n ordered.push({ name, generation });\n }\n ordered.sort((left, right) => left.generation - right.generation);\n if (ordered.length === 0) {\n return readLegacySharedStateLeaseEffect(niceevalRoot, key).pipe(Effect.map((legacy): SharedStateLedger => Object.freeze({\n dir,\n latest: legacy === undefined ? undefined : Object.freeze({ kind: \"legacy\" as const, record: legacy }),\n })));\n }\n return Effect.forEach(ordered, ({ name, generation }) => nodeIo(() => readFile(join(dir, name), \"utf8\")).pipe(Effect.flatMap((raw) => nodeSync(() => JSON.parse(raw))), Effect.flatMap((value) => {\n const decoded = decodeGeneration(key, value);\n return decoded === undefined\n ? Effect.fail(invalidLeaseError(key, `generation ${generation} cannot be decoded`))\n : Effect.succeed({ generation, state: decoded });\n }))).pipe(Effect.flatMap((entries) => readLegacySharedStateLeaseEffect(niceevalRoot, key).pipe(Effect.flatMap((legacy): Effect.Effect<SharedStateLedger, SharedStateLeaseError> => {\n const invalid = validateGenerationTransitions(key, entries, legacy);\n return invalid === undefined\n ? Effect.succeed(Object.freeze({ dir, latest: entries.at(-1)!.state }))\n : Effect.fail(invalid);\n }))));\n }));\n}\n/**\n * Publish one immutable generation. `link(proposal, generation-N)` is the\n * linearization point: it succeeds only if no other transition has occupied\n * the same next-generation slot. The proposal is unique and non-authoritative\n * before the link, so a crash cannot leave a reusable fence or an ABA target.\n */\nfunction publishGenerationExclusiveEffect(dir: string, generation: number, state: SharedStateGeneration): Effect.Effect<\"published\" | \"occupied\", SharedStateLeaseError | unknown> {\n const name = generationFileName(generation);\n const proposalPath = join(dir, `.${name}.${process.pid}.${randomUUID()}.proposal`);\n const targetPath = join(dir, name);\n const data = state.kind === \"lease\"\n ? durableLeaseGeneration(state.record)\n : state.kind === \"free\"\n ? durableFreeGeneration(state)\n : undefined;\n if (data === undefined) {\n return Effect.fail(new SharedStateLeaseError(\"shared-state-lease-invalid\", \"A legacy sharedState record cannot be republished without explicit recovery.\"));\n }\n const writeProposal = withOpenFile(proposalPath, \"wx\", (handle) => nodeIo(() => handle.writeFile(JSON.stringify(data, null, 2), \"utf8\")).pipe(Effect.zipRight(nodeIo(() => handle.sync()))));\n return nodeIo(() => mkdir(dir, { recursive: true })).pipe(Effect.zipRight(writeProposal), Effect.zipRight(nodeIo(() => link(proposalPath, targetPath)).pipe(Effect.as(\"published\" as const), Effect.catchAll((cause) => errnoCode(cause) === \"EEXIST\" ? Effect.succeed(\"occupied\" as const) : Effect.fail(cause)))), Effect.flatMap((result) => result === \"published\"\n ? fsyncDirEffect(dir).pipe(Effect.as(result))\n : Effect.succeed(result)), \n // Only this caller's random proposal is removed. Published generation\n // files are intentionally never deleted, renamed, or reused.\n Effect.ensuring(nodeIo(() => rm(proposalPath, { force: true })).pipe(Effect.ignore)));\n}\nexport function readSharedStateLeaseEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLeaseRecord | undefined, SharedStateLeaseError | unknown> {\n return readSharedStateLedgerEffect(niceevalRoot, key).pipe(Effect.flatMap((ledger) => {\n const record = leaseRecordOf(ledger.latest);\n return record === undefined\n ? Effect.succeed(undefined)\n // Sidecar I/O is deliberately non-authoritative. A bad/missing read\n // cannot hide or invalidate the immutable lease generation.\n : readDiagnosticHeartbeatEffect(ledger.dir, record).pipe(Effect.catchAll(() => Effect.succeed(record)));\n }));\n}\n/**\n * The public recovery command may show the prior owner after a completed\n * release. This lets it report `AlreadyReleased` without asking users to look\n * at private files; a new active generation still takes precedence and makes\n * an old token fail exact-owner validation.\n */\nexport function readSharedStateLeaseRecoveryTargetEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLeaseRecord | undefined, SharedStateLeaseError | unknown> {\n return readSharedStateLedgerEffect(niceevalRoot, key).pipe(Effect.flatMap((ledger) => {\n const record = ledger.latest?.kind === \"free\" ? ledger.latest.previous : leaseRecordOf(ledger.latest);\n return record === undefined\n ? Effect.succeed(undefined)\n : readDiagnosticHeartbeatEffect(ledger.dir, record).pipe(Effect.catchAll(() => Effect.succeed(record)));\n }));\n}\nfunction makeAbortError(signal: AbortSignal | undefined): Error {\n const reason = signal?.reason;\n if (reason instanceof Error)\n return reason;\n const error = new Error(\"aborted while waiting for shared-state recovery\");\n error.name = \"AbortError\";\n return error;\n}\nfunction awaitAbort(signal: AbortSignal | undefined): Effect.Effect<never, Error> {\n if (signal === undefined)\n return Effect.never;\n return Effect.async((resume, effectSignal) => {\n let completed = false;\n const cleanup = (): void => {\n signal.removeEventListener(\"abort\", onAbort);\n effectSignal.removeEventListener(\"abort\", onEffectAbort);\n };\n const complete = (): void => {\n if (completed)\n return;\n completed = true;\n cleanup();\n };\n const onAbort = (): void => {\n if (completed)\n return;\n complete();\n resume(Effect.fail(makeAbortError(signal)));\n };\n const onEffectAbort = (): void => complete();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n effectSignal.addEventListener(\"abort\", onEffectAbort, { once: true });\n // Both listeners must be live before inspecting either signal: otherwise\n // an abort between inspection and registration could strand the waiter.\n if (effectSignal.aborted)\n onEffectAbort();\n else if (signal.aborted)\n onAbort();\n return Effect.sync(complete);\n });\n}\nfunction delayOrAbortEffect(ms: number, signal: AbortSignal | undefined): Effect.Effect<void, Error> {\n if (signal?.aborted)\n return Effect.fail(makeAbortError(signal));\n return Effect.raceFirst(Effect.sleep(ms), awaitAbort(signal)).pipe(Effect.asVoid);\n}\n/**\n * Returns a host-local process identity that distinguishes a PID reuse. Linux\n * uses the kernel start tick plus `/proc`'s terminal-state boundary; other\n * POSIX hosts use `ps`'s process start time. An absent or terminal process\n * returns undefined; unreadable or malformed identity evidence fails closed.\n */\nexport function processIdentityForPidEffect(pid: number): Effect.Effect<string | undefined, unknown> {\n return Effect.tryPromise({\n try: async () => {\n if (process.platform === \"linux\") {\n try {\n const raw = await readFile(`/proc/${pid}/stat`, \"utf8\");\n const closing = raw.lastIndexOf(\")\");\n if (closing < 0 || raw[closing + 1] !== \" \") {\n throw new Error(\"Could not parse /proc/<pid>/stat process identity.\");\n }\n const fields = raw.slice(closing + 2).trim().split(/\\s+/u);\n const state = fields[0];\n // field 3 is the task state. A zombie or either Linux dead state\n // cannot execute the owner cleanup, even though its start tick still\n // matches the durable lease. Treat only these exact terminal states\n // as stopped; a missing or malformed state remains unavailable.\n if (state === \"Z\" || state === \"X\" || state === \"x\")\n return undefined;\n if (state === undefined || !/^[A-Za-z]$/u.test(state)) {\n throw new Error(\"Could not parse /proc/<pid>/stat process state.\");\n }\n // /proc/<pid>/stat field 22 is starttime; `fields[0]` is field 3.\n const started = fields[19];\n if (started !== undefined && /^\\d+$/u.test(started))\n return `linux-starttime:${started}`;\n throw new Error(\"Could not parse /proc/<pid>/stat process identity.\");\n }\n catch (cause) {\n if (errnoCode(cause) === \"ENOENT\")\n return undefined;\n throw cause;\n }\n }\n return await new Promise<string | undefined>((resolve, reject) => {\n execFile(\"ps\", [\"-o\", \"lstart=\", \"-p\", String(pid)], { encoding: \"utf8\" }, (error, stdout) => {\n if (error !== null) {\n if (stdout.trim().length === 0)\n resolve(undefined);\n else\n reject(error);\n return;\n }\n const started = stdout.trim();\n resolve(started.length === 0 ? undefined : `ps-lstart:${started}`);\n });\n });\n },\n catch: (cause) => cause,\n });\n}\nexport function currentProcessIdentityEffect(): Effect.Effect<string, SharedStateLeaseError | unknown> {\n return processIdentityForPidEffect(process.pid).pipe(Effect.flatMap((identity) => identity === undefined\n ? Effect.fail(new SharedStateLeaseError(\"shared-state-process-identity-unavailable\", \"NiceEval could not establish this process identity; sharedState fails closed rather than coordinating from a PID alone.\"))\n : Effect.succeed(identity)));\n}\nfunction recoveryActor(host: string, processIdentity: string): SharedStateRecoveryActor {\n return Object.freeze({\n pid: process.pid,\n host,\n processIdentity,\n startedAt: new Date().toISOString(),\n });\n}\n/**\n * Heartbeats intentionally make no authority transition. They verify that the\n * exact immutable generation/token is still current, then atomically replace\n * only that generation's diagnostic sidecar. A sidecar failure is ignored and\n * cannot expire, take over, or resurrect any owner.\n */\nfunction heartbeatEffect(niceevalRoot: string, key: string, expected: SharedStateLeaseRecord): Effect.Effect<\"confirmed\" | \"lost\", SharedStateLeaseError | unknown> {\n return readSharedStateLedgerEffect(niceevalRoot, key).pipe(Effect.flatMap((ledger) => {\n const current = leaseRecordOf(ledger.latest);\n if (current === undefined || !sameLeaseRecord(current, expected))\n return Effect.succeed(\"lost\" as const);\n return Clock.currentTimeMillis.pipe(Effect.flatMap((nowMs) => writeDiagnosticHeartbeatEffect(ledger.dir, expected, new Date(nowMs).toISOString()).pipe(\n // This write is merely user-facing evidence. The immutable head is\n // still authoritative even if the filesystem rejects the sidecar.\n Effect.catchAll(() => Effect.void), Effect.as(\"confirmed\" as const))));\n }));\n}\nfunction makeActiveLeaseRecord(input: {\n readonly key: string;\n readonly identity: SharedStateLeaseIdentity;\n readonly ownerToken: string;\n readonly generation: number;\n readonly parentGeneration: number;\n readonly now: string;\n}): SharedStateLeaseRecord {\n return Object.freeze({\n key: input.key,\n experimentId: input.identity.experimentId,\n ownerToken: input.ownerToken,\n pid: input.identity.pid,\n host: input.identity.host,\n processIdentity: input.identity.processIdentity,\n acquiredAt: input.now,\n heartbeatAt: input.now,\n status: \"active\",\n generation: input.generation,\n parentGeneration: input.parentGeneration,\n });\n}\nfunction freeGenerationFrom(record: SharedStateLeaseRecord, generation: number, releasedAt: string): SharedStateFreeGeneration {\n return Object.freeze({\n kind: \"free\",\n key: record.key,\n generation,\n parentGeneration: record.generation,\n releasedAt,\n previous: record,\n });\n}\nfunction releaseError(key: string, latest: SharedStateGeneration | undefined): SharedStateLeaseError {\n return new SharedStateLeaseError(latest === undefined ? \"shared-state-lease-missing\" : \"shared-state-lease-owner-mismatch\", `sharedState lease ${JSON.stringify(key)} was not released because its exact owner generation no longer matches; explicit recovery is required.`);\n}\n/**\n * Advance exactly this active generation to a free generation. A competing\n * transition can only occupy the same next slot; after that happens we inspect\n * the new immutable head and accept it only if it is this exact release.\n */\nfunction releaseExactLeaseEffect(niceevalRoot: string, key: string, expected: SharedStateLeaseRecord): Effect.Effect<void, SharedStateLeaseError | unknown> {\n return Effect.suspend(() => readSharedStateLedgerEffect(niceevalRoot, key).pipe(Effect.flatMap((ledger) => {\n if (ledger.latest?.kind === \"free\" && sameLeaseRecord(ledger.latest.previous, expected))\n return Effect.void;\n const current = leaseRecordOf(ledger.latest);\n if (current === undefined || !sameLeaseRecord(current, expected))\n return Effect.fail(releaseError(key, ledger.latest));\n const next = freeGenerationFrom(expected, expected.generation + 1, new Date().toISOString());\n return publishGenerationExclusiveEffect(ledger.dir, next.generation, next).pipe(Effect.flatMap((published) => published === \"published\" ? Effect.void : releaseExactLeaseEffect(niceevalRoot, key, expected)));\n })));\n}\n/**\n * Acquires only a free/absent generation head. Existing active/recovering\n * leases are waited on indefinitely; heartbeat age and PID liveness are\n * diagnostic facts, never authority to take ownership.\n */\nexport function acquireSharedStateLeaseEffect(niceevalRoot: string, key: string, identity: SharedStateLeaseIdentity, opts: {\n readonly signal?: AbortSignal;\n readonly pollIntervalMs?: number;\n readonly heartbeatIntervalMs?: number;\n readonly onWaitStart?: (holder: SharedStateLeaseRecord) => void;\n} = {}): Effect.Effect<AcquireSharedStateLeaseEffectResult, SharedStateLeaseError | unknown> {\n const ownerToken = randomUUID();\n const pollIntervalMs = opts.pollIntervalMs ?? SHARED_STATE_LEASE_HEARTBEAT_INTERVAL_MS;\n const heartbeatIntervalMs = opts.heartbeatIntervalMs ?? SHARED_STATE_LEASE_HEARTBEAT_INTERVAL_MS;\n let waitReported = false;\n const acquire = (): Effect.Effect<SharedStateLeaseRecord, SharedStateLeaseError | unknown> => Effect.suspend(() => {\n if (opts.signal?.aborted)\n return Effect.fail(makeAbortError(opts.signal));\n return readSharedStateLedgerEffect(niceevalRoot, key).pipe(Effect.flatMap((ledger) => {\n const holder = leaseRecordOf(ledger.latest);\n if (holder !== undefined) {\n const reportWait = waitReported\n ? Effect.void\n : readDiagnosticHeartbeatEffect(ledger.dir, holder).pipe(Effect.flatMap((displayHolder) => Effect.sync(() => {\n waitReported = true;\n opts.onWaitStart?.(displayHolder);\n })));\n return reportWait.pipe(Effect.zipRight(delayOrAbortEffect(pollIntervalMs, opts.signal)), Effect.zipRight(acquire()));\n }\n return Clock.currentTimeMillis.pipe(Effect.flatMap((nowMs) => {\n const parentGeneration = generationNumber(ledger.latest);\n const record = makeActiveLeaseRecord({\n key,\n identity,\n ownerToken,\n generation: parentGeneration + 1,\n parentGeneration,\n now: new Date(nowMs).toISOString(),\n });\n const next: SharedStateGeneration = Object.freeze({ kind: \"lease\" as const, record });\n return publishGenerationExclusiveEffect(ledger.dir, record.generation, next).pipe(Effect.flatMap((published) => published === \"published\" ? Effect.succeed(record) : acquire()));\n }));\n }));\n });\n return Effect.uninterruptibleMask((restore) => restore(acquire()).pipe(Effect.flatMap((record) => {\n let heartbeatStopped = false;\n let lostOwnership = false;\n const heartbeat = Effect.forever(Effect.sleep(heartbeatIntervalMs).pipe(Effect.zipRight(heartbeatEffect(niceevalRoot, key, record).pipe(Effect.tap((outcome) => Effect.sync(() => {\n if (outcome === \"lost\")\n lostOwnership = true;\n })), \n // A diagnostic probe failure does not silently abandon an\n // otherwise-owned lease; release still performs the exact CAS.\n Effect.ignore))));\n return Effect.forkDaemon(restore(heartbeat)).pipe(Effect.flatMap((fiber) => Deferred.make<void, SharedStateLeaseError | unknown>().pipe(Effect.map((releaseCompletion) => {\n const stopHeartbeat = Effect.uninterruptible(Effect.suspend(() => {\n if (heartbeatStopped)\n return Effect.void;\n heartbeatStopped = true;\n return Fiber.interrupt(fiber).pipe(Effect.asVoid);\n }));\n const releaseOperation = stopHeartbeat.pipe(Effect.zipRight(releaseExactLeaseEffect(niceevalRoot, key, record)), Effect.catchAll((cause) => {\n // Keep the exact failure visible to the caller. `lostOwnership`\n // only improves the diagnosis; it never changes authority.\n if (cause instanceof SharedStateLeaseError)\n return Effect.fail(cause);\n return Effect.fail(lostOwnership\n ? new SharedStateLeaseError(\"shared-state-lease-owner-mismatch\", `sharedState lease ${JSON.stringify(key)} changed while this owner was active; explicit recovery is required.`)\n : cause);\n }));\n const release = Effect.uninterruptible(Deferred.complete(releaseCompletion, releaseOperation).pipe(Effect.zipRight(Deferred.await(releaseCompletion))));\n return Object.freeze({ claim: Object.freeze({ ownerToken, release, abandon: stopHeartbeat }) });\n }))));\n })));\n}\nfunction assertRecoveryConfirmed(input: {\n readonly confirmOwnerTerminated: boolean;\n readonly confirmRemoteQuiesced: boolean;\n}): Effect.Effect<void, SharedStateLeaseError> {\n return input.confirmOwnerTerminated && input.confirmRemoteQuiesced\n ? Effect.void\n : Effect.fail(new SharedStateLeaseError(\"shared-state-recovery-confirmation-required\", \"Shared-state recovery requires explicit confirmation that the owner terminated and remote state is quiesced.\"));\n}\n/** A local identity mismatch proves PID reuse; an unreadable identity fails closed. */\nfunction assertActorStoppedEffect(actor: Pick<SharedStateRecoveryActor, \"pid\" | \"host\" | \"processIdentity\">, localHost: string, code: \"shared-state-owner-still-live\" | \"shared-state-recovery-in-progress\", remoteQuiesced: boolean): Effect.Effect<void, SharedStateLeaseError | unknown> {\n if (actor.host !== localHost) {\n return remoteQuiesced\n ? Effect.void\n : Effect.fail(new SharedStateLeaseError(\"shared-state-recovery-identity-unavailable\", `NiceEval cannot verify remote owner ${actor.host} without an explicit remote-quiesced acknowledgement.`));\n }\n return processIdentityForPidEffect(actor.pid).pipe(Effect.mapError(() => new SharedStateLeaseError(\"shared-state-recovery-identity-unavailable\", `NiceEval could not verify local process identity for PID ${actor.pid}; recovery fails closed.`)), Effect.flatMap((current) => {\n if (current === undefined || current !== actor.processIdentity)\n return Effect.void;\n return Effect.fail(new SharedStateLeaseError(code, code === \"shared-state-owner-still-live\"\n ? `sharedState owner is still live on ${actor.host} as PID ${actor.pid}; recovery is refused.`\n : `A prior sharedState recovery is still live on ${actor.host} as PID ${actor.pid}; recovery is refused.`));\n }));\n}\nfunction recoveryRecordFrom(source: SharedStateLeaseRecord, recoveryId: string, actor: SharedStateRecoveryActor): SharedStateLeaseRecord {\n return Object.freeze({\n ...source,\n status: \"recovering\",\n generation: source.generation + 1,\n parentGeneration: source.generation,\n recoveryId,\n recoveryActor: actor,\n });\n}\nfunction isExactRecoveringSource(record: SharedStateLeaseRecord, recoveryId: string, actor: SharedStateRecoveryActor): boolean {\n return record.status === \"recovering\" &&\n record.recoveryId === recoveryId &&\n record.recoveryActor !== undefined &&\n // Do not reduce this to processIdentity: PID, host, and the immutable\n // recovery id are all part of the replacement compare-owner predicate.\n sameRecoveryActor(record.recoveryActor, actor);\n}\n/**\n * Claims a failed holder for one recovery command without releasing it. The\n * recovery record is an immutable next generation. If two operators recover\n * concurrently, only one can publish that exact next slot; the loser never\n * clears or reuses a coordination path and must re-inspect/retry explicitly.\n */\nexport function beginExplicitSharedStateRecoveryEffect(input: {\n readonly niceevalRoot: string;\n readonly key: string;\n readonly ownerToken: string;\n readonly localHost: string;\n readonly confirmOwnerTerminated: boolean;\n readonly confirmRemoteQuiesced: boolean;\n}): Effect.Effect<ExplicitSharedStateRecovery, SharedStateLeaseError | unknown> {\n return Effect.gen(function* () {\n yield* assertRecoveryConfirmed(input);\n const processIdentity = yield* currentProcessIdentityEffect();\n const actor = recoveryActor(input.localHost, processIdentity);\n const ledger = yield* readSharedStateLedgerEffect(input.niceevalRoot, input.key);\n if (ledger.latest === undefined) {\n return yield* Effect.fail(new SharedStateLeaseError(\"shared-state-lease-missing\", `No decodable sharedState lease exists for ${JSON.stringify(input.key)}.`));\n }\n if (ledger.latest.kind === \"free\") {\n if (ledger.latest.previous.ownerToken === input.ownerToken) {\n return Object.freeze({ _tag: \"AlreadyReleased\" as const, record: ledger.latest.previous });\n }\n return yield* Effect.fail(new SharedStateLeaseError(\"shared-state-lease-owner-mismatch\", `The supplied owner token does not own sharedState key ${JSON.stringify(input.key)}.`));\n }\n const observed = ledger.latest.record;\n if (observed.ownerToken !== input.ownerToken) {\n return yield* Effect.fail(new SharedStateLeaseError(\"shared-state-lease-owner-mismatch\", `The supplied owner token does not own sharedState key ${JSON.stringify(input.key)}.`));\n }\n yield* assertActorStoppedEffect(observed, input.localHost, \"shared-state-owner-still-live\", input.confirmRemoteQuiesced);\n if (observed.status === \"recovering\") {\n const observedRecoveryId = observed.recoveryId!;\n const observedRecoveryActor = observed.recoveryActor!;\n // The observed immutable parent itself is the exact compare-owner input.\n // Keep the full predicate explicit so a PID/processIdentity coincidence\n // cannot replace a different recovery operation.\n if (!isExactRecoveringSource(observed, observedRecoveryId, observedRecoveryActor)) {\n return yield* Effect.fail(invalidLeaseError(input.key, \"recovering generation lacks an exact recovery actor\"));\n }\n yield* assertActorStoppedEffect(observedRecoveryActor, input.localHost, \"shared-state-recovery-in-progress\", input.confirmRemoteQuiesced);\n }\n const recoveryId = randomUUID();\n const recovered = recoveryRecordFrom(observed, recoveryId, actor);\n const next: SharedStateGeneration = Object.freeze({ kind: \"lease\" as const, record: recovered });\n const published = yield* publishGenerationExclusiveEffect(ledger.dir, recovered.generation, next);\n if (published === \"published\")\n return Object.freeze({ _tag: \"Claimed\" as const, record: recovered, recoveryId });\n return yield* Effect.fail(new SharedStateLeaseError(\"shared-state-recovery-state-mismatch\", `sharedState lease ${JSON.stringify(input.key)} changed before explicit recovery could claim its exact generation.`));\n });\n}\nfunction exactRecoveryActorMatchesCurrentProcess(actor: SharedStateRecoveryActor, localHost: string, processIdentity: string): boolean {\n return actor.pid === process.pid && actor.host === localHost && actor.processIdentity === processIdentity;\n}\n/**\n * Final recovery transition: exactly owner token + recovery id + recovery\n * actor host/PID/process identity advances its observed generation to free.\n * It does not unlink anything and therefore cannot erase a later holder.\n */\nexport function completeExplicitSharedStateRecoveryEffect(input: {\n readonly niceevalRoot: string;\n readonly key: string;\n readonly ownerToken: string;\n readonly recoveryId: string;\n readonly localHost: string;\n}): Effect.Effect<void, SharedStateLeaseError | unknown> {\n const complete = (expected?: SharedStateLeaseRecord): Effect.Effect<void, SharedStateLeaseError | unknown> => Effect.suspend(() => readSharedStateLedgerEffect(input.niceevalRoot, input.key).pipe(Effect.flatMap((ledger) => {\n if (ledger.latest?.kind === \"free\" && expected !== undefined && sameLeaseRecord(ledger.latest.previous, expected)) {\n return Effect.void;\n }\n const current = leaseRecordOf(ledger.latest);\n if (current === undefined ||\n (expected !== undefined && !sameLeaseRecord(current, expected)) ||\n current.ownerToken !== input.ownerToken ||\n current.status !== \"recovering\" ||\n current.recoveryId !== input.recoveryId ||\n current.recoveryActor === undefined) {\n return Effect.fail(new SharedStateLeaseError(ledger.latest === undefined ? \"shared-state-lease-missing\" : \"shared-state-recovery-state-mismatch\", `sharedState lease ${JSON.stringify(input.key)} no longer matches this explicit recovery operation.`));\n }\n return currentProcessIdentityEffect().pipe(Effect.flatMap((processIdentity) => {\n if (!exactRecoveryActorMatchesCurrentProcess(current.recoveryActor!, input.localHost, processIdentity)) {\n return Effect.fail(new SharedStateLeaseError(\"shared-state-recovery-state-mismatch\", `sharedState lease ${JSON.stringify(input.key)} is not owned by this exact recovery actor.`));\n }\n const next = freeGenerationFrom(current, current.generation + 1, new Date().toISOString());\n return publishGenerationExclusiveEffect(ledger.dir, next.generation, next).pipe(Effect.flatMap((published) => published === \"published\" ? Effect.void : complete(current)));\n }));\n })));\n return complete();\n}\n"]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
export declare const SHARED_STATE_LEASE_HEARTBEAT_INTERVAL_MS = 10000;
|
|
3
|
+
export type SharedStateLeaseStatus = "active" | "recovering";
|
|
4
|
+
/** The process currently running an explicit recovery hook. */
|
|
5
|
+
export interface SharedStateRecoveryActor {
|
|
6
|
+
readonly pid: number;
|
|
7
|
+
readonly host: string;
|
|
8
|
+
readonly processIdentity: string;
|
|
9
|
+
readonly startedAt: string;
|
|
10
|
+
}
|
|
11
|
+
/** Durable, human-readable ownership evidence. The owner token is immutable. */
|
|
12
|
+
export interface SharedStateLeaseRecord {
|
|
13
|
+
readonly key: string;
|
|
14
|
+
readonly experimentId: string;
|
|
15
|
+
readonly ownerToken: string;
|
|
16
|
+
readonly pid: number;
|
|
17
|
+
readonly host: string;
|
|
18
|
+
readonly processIdentity: string;
|
|
19
|
+
readonly acquiredAt: string;
|
|
20
|
+
/**
|
|
21
|
+
* Public diagnostic heartbeat time. The immutable generation starts it at
|
|
22
|
+
* acquisition; public reads may overlay a matching non-authoritative
|
|
23
|
+
* sidecar. Heartbeats never grant authority.
|
|
24
|
+
*/
|
|
25
|
+
readonly heartbeatAt: string;
|
|
26
|
+
readonly status: SharedStateLeaseStatus;
|
|
27
|
+
/** Immutable transition generation which made this record authoritative. */
|
|
28
|
+
readonly generation: number;
|
|
29
|
+
/** The exact prior authoritative generation (zero for a fresh chain). */
|
|
30
|
+
readonly parentGeneration: number;
|
|
31
|
+
/** Present only while an explicit CLI recovery is holding the lease closed. */
|
|
32
|
+
readonly recoveryId?: string;
|
|
33
|
+
readonly recoveryActor?: SharedStateRecoveryActor;
|
|
34
|
+
}
|
|
35
|
+
export interface SharedStateLeaseIdentity {
|
|
36
|
+
readonly experimentId: string;
|
|
37
|
+
readonly pid: number;
|
|
38
|
+
readonly host: string;
|
|
39
|
+
readonly processIdentity: string;
|
|
40
|
+
}
|
|
41
|
+
export declare class SharedStateLeaseError extends Error {
|
|
42
|
+
readonly code: "shared-state-lease-invalid" | "shared-state-lease-owner-mismatch" | "shared-state-lease-missing" | "shared-state-owner-still-live" | "shared-state-process-identity-unavailable" | "shared-state-recovery-confirmation-required" | "shared-state-recovery-state-mismatch" | "shared-state-recovery-in-progress" | "shared-state-recovery-identity-unavailable";
|
|
43
|
+
constructor(code: "shared-state-lease-invalid" | "shared-state-lease-owner-mismatch" | "shared-state-lease-missing" | "shared-state-owner-still-live" | "shared-state-process-identity-unavailable" | "shared-state-recovery-confirmation-required" | "shared-state-recovery-state-mismatch" | "shared-state-recovery-in-progress" | "shared-state-recovery-identity-unavailable", message: string);
|
|
44
|
+
}
|
|
45
|
+
export interface SharedStateLeaseEffectClaim {
|
|
46
|
+
readonly ownerToken: string;
|
|
47
|
+
/** Releases only this exact owner generation. It never deletes a newer holder. */
|
|
48
|
+
readonly release: Effect.Effect<void, SharedStateLeaseError | unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* Stops this process's diagnostic heartbeat without mutating the durable
|
|
51
|
+
* lease. Cleanup failures use this path: the record must survive for an
|
|
52
|
+
* explicit recovery, but it must not keep the finished CLI process alive.
|
|
53
|
+
*/
|
|
54
|
+
readonly abandon: Effect.Effect<void>;
|
|
55
|
+
}
|
|
56
|
+
export interface AcquireSharedStateLeaseEffectResult {
|
|
57
|
+
readonly claim: SharedStateLeaseEffectClaim;
|
|
58
|
+
}
|
|
59
|
+
/** A recovery either owns a durable recovery marker or found a completed release. */
|
|
60
|
+
export type ExplicitSharedStateRecovery = {
|
|
61
|
+
readonly _tag: "Claimed";
|
|
62
|
+
readonly record: SharedStateLeaseRecord;
|
|
63
|
+
readonly recoveryId: string;
|
|
64
|
+
} | {
|
|
65
|
+
readonly _tag: "AlreadyReleased";
|
|
66
|
+
readonly record: SharedStateLeaseRecord;
|
|
67
|
+
};
|
|
68
|
+
export declare function sharedStateLeasesDirOf(niceevalRoot: string): string;
|
|
69
|
+
export declare function readSharedStateLeaseEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLeaseRecord | undefined, SharedStateLeaseError | unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* The public recovery command may show the prior owner after a completed
|
|
72
|
+
* release. This lets it report `AlreadyReleased` without asking users to look
|
|
73
|
+
* at private files; a new active generation still takes precedence and makes
|
|
74
|
+
* an old token fail exact-owner validation.
|
|
75
|
+
*/
|
|
76
|
+
export declare function readSharedStateLeaseRecoveryTargetEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLeaseRecord | undefined, SharedStateLeaseError | unknown>;
|
|
77
|
+
/**
|
|
78
|
+
* Returns a host-local process identity that distinguishes a PID reuse. Linux
|
|
79
|
+
* uses the kernel start tick plus `/proc`'s terminal-state boundary; other
|
|
80
|
+
* POSIX hosts use `ps`'s process start time. An absent or terminal process
|
|
81
|
+
* returns undefined; unreadable or malformed identity evidence fails closed.
|
|
82
|
+
*/
|
|
83
|
+
export declare function processIdentityForPidEffect(pid: number): Effect.Effect<string | undefined, unknown>;
|
|
84
|
+
export declare function currentProcessIdentityEffect(): Effect.Effect<string, SharedStateLeaseError | unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Acquires only a free/absent generation head. Existing active/recovering
|
|
87
|
+
* leases are waited on indefinitely; heartbeat age and PID liveness are
|
|
88
|
+
* diagnostic facts, never authority to take ownership.
|
|
89
|
+
*/
|
|
90
|
+
export declare function acquireSharedStateLeaseEffect(niceevalRoot: string, key: string, identity: SharedStateLeaseIdentity, opts?: {
|
|
91
|
+
readonly signal?: AbortSignal;
|
|
92
|
+
readonly pollIntervalMs?: number;
|
|
93
|
+
readonly heartbeatIntervalMs?: number;
|
|
94
|
+
readonly onWaitStart?: (holder: SharedStateLeaseRecord) => void;
|
|
95
|
+
}): Effect.Effect<AcquireSharedStateLeaseEffectResult, SharedStateLeaseError | unknown>;
|
|
96
|
+
/**
|
|
97
|
+
* Claims a failed holder for one recovery command without releasing it. The
|
|
98
|
+
* recovery record is an immutable next generation. If two operators recover
|
|
99
|
+
* concurrently, only one can publish that exact next slot; the loser never
|
|
100
|
+
* clears or reuses a coordination path and must re-inspect/retry explicitly.
|
|
101
|
+
*/
|
|
102
|
+
export declare function beginExplicitSharedStateRecoveryEffect(input: {
|
|
103
|
+
readonly niceevalRoot: string;
|
|
104
|
+
readonly key: string;
|
|
105
|
+
readonly ownerToken: string;
|
|
106
|
+
readonly localHost: string;
|
|
107
|
+
readonly confirmOwnerTerminated: boolean;
|
|
108
|
+
readonly confirmRemoteQuiesced: boolean;
|
|
109
|
+
}): Effect.Effect<ExplicitSharedStateRecovery, SharedStateLeaseError | unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* Final recovery transition: exactly owner token + recovery id + recovery
|
|
112
|
+
* actor host/PID/process identity advances its observed generation to free.
|
|
113
|
+
* It does not unlink anything and therefore cannot erase a later holder.
|
|
114
|
+
*/
|
|
115
|
+
export declare function completeExplicitSharedStateRecoveryEffect(input: {
|
|
116
|
+
readonly niceevalRoot: string;
|
|
117
|
+
readonly key: string;
|
|
118
|
+
readonly ownerToken: string;
|
|
119
|
+
readonly recoveryId: string;
|
|
120
|
+
readonly localHost: string;
|
|
121
|
+
}): Effect.Effect<void, SharedStateLeaseError | unknown>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
export declare const SHARED_STATE_LEASE_HEARTBEAT_INTERVAL_MS = 10000;
|
|
3
|
+
export type SharedStateLeaseStatus = "active" | "recovering";
|
|
4
|
+
/** The process currently running an explicit recovery hook. */
|
|
5
|
+
export interface SharedStateRecoveryActor {
|
|
6
|
+
readonly pid: number;
|
|
7
|
+
readonly host: string;
|
|
8
|
+
readonly processIdentity: string;
|
|
9
|
+
readonly startedAt: string;
|
|
10
|
+
}
|
|
11
|
+
/** Durable, human-readable ownership evidence. The owner token is immutable. */
|
|
12
|
+
export interface SharedStateLeaseRecord {
|
|
13
|
+
readonly key: string;
|
|
14
|
+
readonly experimentId: string;
|
|
15
|
+
readonly ownerToken: string;
|
|
16
|
+
readonly pid: number;
|
|
17
|
+
readonly host: string;
|
|
18
|
+
readonly processIdentity: string;
|
|
19
|
+
readonly acquiredAt: string;
|
|
20
|
+
/**
|
|
21
|
+
* Public diagnostic heartbeat time. The immutable generation starts it at
|
|
22
|
+
* acquisition; public reads may overlay a matching non-authoritative
|
|
23
|
+
* sidecar. Heartbeats never grant authority.
|
|
24
|
+
*/
|
|
25
|
+
readonly heartbeatAt: string;
|
|
26
|
+
readonly status: SharedStateLeaseStatus;
|
|
27
|
+
/** Immutable transition generation which made this record authoritative. */
|
|
28
|
+
readonly generation: number;
|
|
29
|
+
/** The exact prior authoritative generation (zero for a fresh chain). */
|
|
30
|
+
readonly parentGeneration: number;
|
|
31
|
+
/** Present only while an explicit CLI recovery is holding the lease closed. */
|
|
32
|
+
readonly recoveryId?: string;
|
|
33
|
+
readonly recoveryActor?: SharedStateRecoveryActor;
|
|
34
|
+
}
|
|
35
|
+
export interface SharedStateLeaseIdentity {
|
|
36
|
+
readonly experimentId: string;
|
|
37
|
+
readonly pid: number;
|
|
38
|
+
readonly host: string;
|
|
39
|
+
readonly processIdentity: string;
|
|
40
|
+
}
|
|
41
|
+
export declare class SharedStateLeaseError extends Error {
|
|
42
|
+
readonly code: "shared-state-lease-invalid" | "shared-state-lease-owner-mismatch" | "shared-state-lease-missing" | "shared-state-owner-still-live" | "shared-state-process-identity-unavailable" | "shared-state-recovery-confirmation-required" | "shared-state-recovery-state-mismatch" | "shared-state-recovery-in-progress" | "shared-state-recovery-identity-unavailable";
|
|
43
|
+
constructor(code: "shared-state-lease-invalid" | "shared-state-lease-owner-mismatch" | "shared-state-lease-missing" | "shared-state-owner-still-live" | "shared-state-process-identity-unavailable" | "shared-state-recovery-confirmation-required" | "shared-state-recovery-state-mismatch" | "shared-state-recovery-in-progress" | "shared-state-recovery-identity-unavailable", message: string);
|
|
44
|
+
}
|
|
45
|
+
export interface SharedStateLeaseEffectClaim {
|
|
46
|
+
readonly ownerToken: string;
|
|
47
|
+
/** Releases only this exact owner generation. It never deletes a newer holder. */
|
|
48
|
+
readonly release: Effect.Effect<void, SharedStateLeaseError | unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* Stops this process's diagnostic heartbeat without mutating the durable
|
|
51
|
+
* lease. Cleanup failures use this path: the record must survive for an
|
|
52
|
+
* explicit recovery, but it must not keep the finished CLI process alive.
|
|
53
|
+
*/
|
|
54
|
+
readonly abandon: Effect.Effect<void>;
|
|
55
|
+
}
|
|
56
|
+
export interface AcquireSharedStateLeaseEffectResult {
|
|
57
|
+
readonly claim: SharedStateLeaseEffectClaim;
|
|
58
|
+
}
|
|
59
|
+
/** A recovery either owns a durable recovery marker or found a completed release. */
|
|
60
|
+
export type ExplicitSharedStateRecovery = {
|
|
61
|
+
readonly _tag: "Claimed";
|
|
62
|
+
readonly record: SharedStateLeaseRecord;
|
|
63
|
+
readonly recoveryId: string;
|
|
64
|
+
} | {
|
|
65
|
+
readonly _tag: "AlreadyReleased";
|
|
66
|
+
readonly record: SharedStateLeaseRecord;
|
|
67
|
+
};
|
|
68
|
+
export declare function sharedStateLeasesDirOf(niceevalRoot: string): string;
|
|
69
|
+
export declare function readSharedStateLeaseEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLeaseRecord | undefined, SharedStateLeaseError | unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* The public recovery command may show the prior owner after a completed
|
|
72
|
+
* release. This lets it report `AlreadyReleased` without asking users to look
|
|
73
|
+
* at private files; a new active generation still takes precedence and makes
|
|
74
|
+
* an old token fail exact-owner validation.
|
|
75
|
+
*/
|
|
76
|
+
export declare function readSharedStateLeaseRecoveryTargetEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLeaseRecord | undefined, SharedStateLeaseError | unknown>;
|
|
77
|
+
/**
|
|
78
|
+
* Returns a host-local process identity that distinguishes a PID reuse. Linux
|
|
79
|
+
* uses the kernel start tick plus `/proc`'s terminal-state boundary; other
|
|
80
|
+
* POSIX hosts use `ps`'s process start time. An absent or terminal process
|
|
81
|
+
* returns undefined; unreadable or malformed identity evidence fails closed.
|
|
82
|
+
*/
|
|
83
|
+
export declare function processIdentityForPidEffect(pid: number): Effect.Effect<string | undefined, unknown>;
|
|
84
|
+
export declare function currentProcessIdentityEffect(): Effect.Effect<string, SharedStateLeaseError | unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Acquires only a free/absent generation head. Existing active/recovering
|
|
87
|
+
* leases are waited on indefinitely; heartbeat age and PID liveness are
|
|
88
|
+
* diagnostic facts, never authority to take ownership.
|
|
89
|
+
*/
|
|
90
|
+
export declare function acquireSharedStateLeaseEffect(niceevalRoot: string, key: string, identity: SharedStateLeaseIdentity, opts?: {
|
|
91
|
+
readonly signal?: AbortSignal;
|
|
92
|
+
readonly pollIntervalMs?: number;
|
|
93
|
+
readonly heartbeatIntervalMs?: number;
|
|
94
|
+
readonly onWaitStart?: (holder: SharedStateLeaseRecord) => void;
|
|
95
|
+
}): Effect.Effect<AcquireSharedStateLeaseEffectResult, SharedStateLeaseError | unknown>;
|
|
96
|
+
/**
|
|
97
|
+
* Claims a failed holder for one recovery command without releasing it. The
|
|
98
|
+
* recovery record is an immutable next generation. If two operators recover
|
|
99
|
+
* concurrently, only one can publish that exact next slot; the loser never
|
|
100
|
+
* clears or reuses a coordination path and must re-inspect/retry explicitly.
|
|
101
|
+
*/
|
|
102
|
+
export declare function beginExplicitSharedStateRecoveryEffect(input: {
|
|
103
|
+
readonly niceevalRoot: string;
|
|
104
|
+
readonly key: string;
|
|
105
|
+
readonly ownerToken: string;
|
|
106
|
+
readonly localHost: string;
|
|
107
|
+
readonly confirmOwnerTerminated: boolean;
|
|
108
|
+
readonly confirmRemoteQuiesced: boolean;
|
|
109
|
+
}): Effect.Effect<ExplicitSharedStateRecovery, SharedStateLeaseError | unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* Final recovery transition: exactly owner token + recovery id + recovery
|
|
112
|
+
* actor host/PID/process identity advances its observed generation to free.
|
|
113
|
+
* It does not unlink anything and therefore cannot erase a later holder.
|
|
114
|
+
*/
|
|
115
|
+
export declare function completeExplicitSharedStateRecoveryEffect(input: {
|
|
116
|
+
readonly niceevalRoot: string;
|
|
117
|
+
readonly key: string;
|
|
118
|
+
readonly ownerToken: string;
|
|
119
|
+
readonly recoveryId: string;
|
|
120
|
+
readonly localHost: string;
|
|
121
|
+
}): Effect.Effect<void, SharedStateLeaseError | unknown>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
export declare const SHARED_STATE_LEASE_HEARTBEAT_INTERVAL_MS = 10000;
|
|
3
|
+
export type SharedStateLeaseStatus = "active" | "recovering";
|
|
4
|
+
/** The process currently running an explicit recovery hook. */
|
|
5
|
+
export interface SharedStateRecoveryActor {
|
|
6
|
+
readonly pid: number;
|
|
7
|
+
readonly host: string;
|
|
8
|
+
readonly processIdentity: string;
|
|
9
|
+
readonly startedAt: string;
|
|
10
|
+
}
|
|
11
|
+
/** Durable, human-readable ownership evidence. The owner token is immutable. */
|
|
12
|
+
export interface SharedStateLeaseRecord {
|
|
13
|
+
readonly key: string;
|
|
14
|
+
readonly experimentId: string;
|
|
15
|
+
readonly ownerToken: string;
|
|
16
|
+
readonly pid: number;
|
|
17
|
+
readonly host: string;
|
|
18
|
+
readonly processIdentity: string;
|
|
19
|
+
readonly acquiredAt: string;
|
|
20
|
+
/**
|
|
21
|
+
* Public diagnostic heartbeat time. The immutable generation starts it at
|
|
22
|
+
* acquisition; public reads may overlay a matching non-authoritative
|
|
23
|
+
* sidecar. Heartbeats never grant authority.
|
|
24
|
+
*/
|
|
25
|
+
readonly heartbeatAt: string;
|
|
26
|
+
readonly status: SharedStateLeaseStatus;
|
|
27
|
+
/** Immutable transition generation which made this record authoritative. */
|
|
28
|
+
readonly generation: number;
|
|
29
|
+
/** The exact prior authoritative generation (zero for a fresh chain). */
|
|
30
|
+
readonly parentGeneration: number;
|
|
31
|
+
/** Present only while an explicit CLI recovery is holding the lease closed. */
|
|
32
|
+
readonly recoveryId?: string;
|
|
33
|
+
readonly recoveryActor?: SharedStateRecoveryActor;
|
|
34
|
+
}
|
|
35
|
+
export interface SharedStateLeaseIdentity {
|
|
36
|
+
readonly experimentId: string;
|
|
37
|
+
readonly pid: number;
|
|
38
|
+
readonly host: string;
|
|
39
|
+
readonly processIdentity: string;
|
|
40
|
+
}
|
|
41
|
+
export declare class SharedStateLeaseError extends Error {
|
|
42
|
+
readonly code: "shared-state-lease-invalid" | "shared-state-lease-owner-mismatch" | "shared-state-lease-missing" | "shared-state-owner-still-live" | "shared-state-process-identity-unavailable" | "shared-state-recovery-confirmation-required" | "shared-state-recovery-state-mismatch" | "shared-state-recovery-in-progress" | "shared-state-recovery-identity-unavailable";
|
|
43
|
+
constructor(code: "shared-state-lease-invalid" | "shared-state-lease-owner-mismatch" | "shared-state-lease-missing" | "shared-state-owner-still-live" | "shared-state-process-identity-unavailable" | "shared-state-recovery-confirmation-required" | "shared-state-recovery-state-mismatch" | "shared-state-recovery-in-progress" | "shared-state-recovery-identity-unavailable", message: string);
|
|
44
|
+
}
|
|
45
|
+
export interface SharedStateLeaseEffectClaim {
|
|
46
|
+
readonly ownerToken: string;
|
|
47
|
+
/** Releases only this exact owner generation. It never deletes a newer holder. */
|
|
48
|
+
readonly release: Effect.Effect<void, SharedStateLeaseError | unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* Stops this process's diagnostic heartbeat without mutating the durable
|
|
51
|
+
* lease. Cleanup failures use this path: the record must survive for an
|
|
52
|
+
* explicit recovery, but it must not keep the finished CLI process alive.
|
|
53
|
+
*/
|
|
54
|
+
readonly abandon: Effect.Effect<void>;
|
|
55
|
+
}
|
|
56
|
+
export interface AcquireSharedStateLeaseEffectResult {
|
|
57
|
+
readonly claim: SharedStateLeaseEffectClaim;
|
|
58
|
+
}
|
|
59
|
+
/** A recovery either owns a durable recovery marker or found a completed release. */
|
|
60
|
+
export type ExplicitSharedStateRecovery = {
|
|
61
|
+
readonly _tag: "Claimed";
|
|
62
|
+
readonly record: SharedStateLeaseRecord;
|
|
63
|
+
readonly recoveryId: string;
|
|
64
|
+
} | {
|
|
65
|
+
readonly _tag: "AlreadyReleased";
|
|
66
|
+
readonly record: SharedStateLeaseRecord;
|
|
67
|
+
};
|
|
68
|
+
export declare function sharedStateLeasesDirOf(niceevalRoot: string): string;
|
|
69
|
+
export declare function readSharedStateLeaseEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLeaseRecord | undefined, SharedStateLeaseError | unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* The public recovery command may show the prior owner after a completed
|
|
72
|
+
* release. This lets it report `AlreadyReleased` without asking users to look
|
|
73
|
+
* at private files; a new active generation still takes precedence and makes
|
|
74
|
+
* an old token fail exact-owner validation.
|
|
75
|
+
*/
|
|
76
|
+
export declare function readSharedStateLeaseRecoveryTargetEffect(niceevalRoot: string, key: string): Effect.Effect<SharedStateLeaseRecord | undefined, SharedStateLeaseError | unknown>;
|
|
77
|
+
/**
|
|
78
|
+
* Returns a host-local process identity that distinguishes a PID reuse. Linux
|
|
79
|
+
* uses the kernel start tick plus `/proc`'s terminal-state boundary; other
|
|
80
|
+
* POSIX hosts use `ps`'s process start time. An absent or terminal process
|
|
81
|
+
* returns undefined; unreadable or malformed identity evidence fails closed.
|
|
82
|
+
*/
|
|
83
|
+
export declare function processIdentityForPidEffect(pid: number): Effect.Effect<string | undefined, unknown>;
|
|
84
|
+
export declare function currentProcessIdentityEffect(): Effect.Effect<string, SharedStateLeaseError | unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Acquires only a free/absent generation head. Existing active/recovering
|
|
87
|
+
* leases are waited on indefinitely; heartbeat age and PID liveness are
|
|
88
|
+
* diagnostic facts, never authority to take ownership.
|
|
89
|
+
*/
|
|
90
|
+
export declare function acquireSharedStateLeaseEffect(niceevalRoot: string, key: string, identity: SharedStateLeaseIdentity, opts?: {
|
|
91
|
+
readonly signal?: AbortSignal;
|
|
92
|
+
readonly pollIntervalMs?: number;
|
|
93
|
+
readonly heartbeatIntervalMs?: number;
|
|
94
|
+
readonly onWaitStart?: (holder: SharedStateLeaseRecord) => void;
|
|
95
|
+
}): Effect.Effect<AcquireSharedStateLeaseEffectResult, SharedStateLeaseError | unknown>;
|
|
96
|
+
/**
|
|
97
|
+
* Claims a failed holder for one recovery command without releasing it. The
|
|
98
|
+
* recovery record is an immutable next generation. If two operators recover
|
|
99
|
+
* concurrently, only one can publish that exact next slot; the loser never
|
|
100
|
+
* clears or reuses a coordination path and must re-inspect/retry explicitly.
|
|
101
|
+
*/
|
|
102
|
+
export declare function beginExplicitSharedStateRecoveryEffect(input: {
|
|
103
|
+
readonly niceevalRoot: string;
|
|
104
|
+
readonly key: string;
|
|
105
|
+
readonly ownerToken: string;
|
|
106
|
+
readonly localHost: string;
|
|
107
|
+
readonly confirmOwnerTerminated: boolean;
|
|
108
|
+
readonly confirmRemoteQuiesced: boolean;
|
|
109
|
+
}): Effect.Effect<ExplicitSharedStateRecovery, SharedStateLeaseError | unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* Final recovery transition: exactly owner token + recovery id + recovery
|
|
112
|
+
* actor host/PID/process identity advances its observed generation to free.
|
|
113
|
+
* It does not unlink anything and therefore cannot erase a later holder.
|
|
114
|
+
*/
|
|
115
|
+
export declare function completeExplicitSharedStateRecoveryEffect(input: {
|
|
116
|
+
readonly niceevalRoot: string;
|
|
117
|
+
readonly key: string;
|
|
118
|
+
readonly ownerToken: string;
|
|
119
|
+
readonly recoveryId: string;
|
|
120
|
+
readonly localHost: string;
|
|
121
|
+
}): Effect.Effect<void, SharedStateLeaseError | unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createRequire as __niceevalCreateRequire } from "node:module";
|
|
2
|
+
const __niceevalRequire = __niceevalCreateRequire(import.meta.url);
|
|
3
|
+
const __niceevalCanonical = __niceevalRequire("./shared-state-lease.cjs");
|
|
4
|
+
const __niceevalExport0 = __niceevalCanonical["SHARED_STATE_LEASE_HEARTBEAT_INTERVAL_MS"];
|
|
5
|
+
export { __niceevalExport0 as SHARED_STATE_LEASE_HEARTBEAT_INTERVAL_MS };
|
|
6
|
+
const __niceevalExport1 = __niceevalCanonical["SharedStateLeaseError"];
|
|
7
|
+
export { __niceevalExport1 as SharedStateLeaseError };
|
|
8
|
+
const __niceevalExport2 = __niceevalCanonical["acquireSharedStateLeaseEffect"];
|
|
9
|
+
export { __niceevalExport2 as acquireSharedStateLeaseEffect };
|
|
10
|
+
const __niceevalExport3 = __niceevalCanonical["beginExplicitSharedStateRecoveryEffect"];
|
|
11
|
+
export { __niceevalExport3 as beginExplicitSharedStateRecoveryEffect };
|
|
12
|
+
const __niceevalExport4 = __niceevalCanonical["completeExplicitSharedStateRecoveryEffect"];
|
|
13
|
+
export { __niceevalExport4 as completeExplicitSharedStateRecoveryEffect };
|
|
14
|
+
const __niceevalExport5 = __niceevalCanonical["currentProcessIdentityEffect"];
|
|
15
|
+
export { __niceevalExport5 as currentProcessIdentityEffect };
|
|
16
|
+
const __niceevalExport6 = __niceevalCanonical["processIdentityForPidEffect"];
|
|
17
|
+
export { __niceevalExport6 as processIdentityForPidEffect };
|
|
18
|
+
const __niceevalExport7 = __niceevalCanonical["readSharedStateLeaseEffect"];
|
|
19
|
+
export { __niceevalExport7 as readSharedStateLeaseEffect };
|
|
20
|
+
const __niceevalExport8 = __niceevalCanonical["readSharedStateLeaseRecoveryTargetEffect"];
|
|
21
|
+
export { __niceevalExport8 as readSharedStateLeaseRecoveryTargetEffect };
|
|
22
|
+
const __niceevalExport9 = __niceevalCanonical["sharedStateLeasesDirOf"];
|
|
23
|
+
export { __niceevalExport9 as sharedStateLeasesDirOf };
|
|
24
|
+
//# sourceMappingURL=shared-state-lease.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-state-lease.js","sources":[],"names":[],"mappings":""}
|