niceeval 0.13.2 → 0.13.3
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/dist/agents/bub.cjs +4 -4
- 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-native.cjs +213 -0
- package/dist/agents/claude-code-native.cjs.map +1 -0
- package/dist/agents/claude-code-native.d.cts +5 -0
- package/dist/agents/claude-code-native.d.mts +5 -0
- package/dist/agents/claude-code-native.d.ts +5 -0
- package/dist/agents/claude-code-native.js +6 -0
- package/dist/agents/claude-code-native.js.map +1 -0
- package/dist/agents/claude-code.cjs +26 -80
- package/dist/agents/claude-code.cjs.map +1 -1
- package/dist/agents/codex-app-server.cjs +314 -0
- package/dist/agents/codex-app-server.cjs.map +1 -0
- package/dist/agents/codex-app-server.d.cts +9 -0
- package/dist/agents/codex-app-server.d.mts +9 -0
- package/dist/agents/codex-app-server.d.ts +9 -0
- package/dist/agents/codex-app-server.js +6 -0
- package/dist/agents/codex-app-server.js.map +1 -0
- package/dist/agents/codex.cjs +19 -68
- 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/index.cjs +3 -1
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +1 -0
- package/dist/agents/index.d.mts +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.js +84 -82
- package/dist/agents/index.mjs +84 -82
- package/dist/agents/managed-jsonl.cjs +207 -0
- package/dist/agents/managed-jsonl.cjs.map +1 -0
- package/dist/agents/managed-jsonl.d.cts +39 -0
- package/dist/agents/managed-jsonl.d.mts +39 -0
- package/dist/agents/managed-jsonl.d.ts +39 -0
- package/dist/agents/managed-jsonl.js +6 -0
- package/dist/agents/managed-jsonl.js.map +1 -0
- package/dist/agents/managed-process.cjs +31 -0
- package/dist/agents/managed-process.cjs.map +1 -0
- package/dist/agents/managed-process.d.cts +3 -0
- package/dist/agents/managed-process.d.mts +3 -0
- package/dist/agents/managed-process.d.ts +3 -0
- package/dist/agents/managed-process.js +6 -0
- package/dist/agents/managed-process.js.map +1 -0
- package/dist/agents/omp.cjs +18 -1
- package/dist/agents/omp.cjs.map +1 -1
- package/dist/agents/sdk-streams.cjs +11 -4
- package/dist/agents/sdk-streams.cjs.map +1 -1
- package/dist/agents/types.cjs.map +1 -1
- package/dist/agents/types.d.cts +8 -0
- package/dist/agents/types.d.mts +8 -0
- package/dist/agents/types.d.ts +8 -0
- package/dist/analysis/bindings.cjs +74 -19
- package/dist/analysis/bindings.cjs.map +1 -1
- package/dist/analysis/bindings.d.cts +534 -156
- package/dist/analysis/bindings.d.mts +534 -156
- package/dist/analysis/bindings.d.ts +534 -156
- package/dist/analysis/domain-view.cjs.map +1 -1
- package/dist/analysis/domain-view.d.cts +137 -8
- package/dist/analysis/domain-view.d.mts +137 -8
- package/dist/analysis/domain-view.d.ts +137 -8
- package/dist/analysis/index.cjs.map +1 -1
- package/dist/analysis/index.d.cts +1 -1
- package/dist/analysis/index.d.mts +1 -1
- package/dist/analysis/index.d.ts +1 -1
- package/dist/assertions/api.cjs.map +1 -1
- package/dist/assertions/api.d.cts +62 -0
- package/dist/assertions/api.d.mts +62 -0
- package/dist/assertions/api.d.ts +62 -0
- package/dist/assertions/judge.cjs +56 -5
- package/dist/assertions/judge.cjs.map +1 -1
- package/dist/assertions/match.cjs +66 -42
- package/dist/assertions/match.cjs.map +1 -1
- package/dist/assertions/match.d.cts +13 -0
- package/dist/assertions/match.d.mts +13 -0
- package/dist/assertions/match.d.ts +13 -0
- package/dist/assertions/record/attachment.cjs +104 -33
- package/dist/assertions/record/attachment.cjs.map +1 -1
- package/dist/assertions/record/attachment.d.cts +294 -57
- package/dist/assertions/record/attachment.d.mts +294 -57
- package/dist/assertions/record/attachment.d.ts +294 -57
- package/dist/assertions/record/codec.cjs +91 -17
- package/dist/assertions/record/codec.cjs.map +1 -1
- package/dist/assertions/record/codec.d.cts +280 -52
- package/dist/assertions/record/codec.d.mts +280 -52
- package/dist/assertions/record/codec.d.ts +280 -52
- package/dist/assertions/record/index.js +2 -0
- package/dist/assertions/record/model.cjs +16 -0
- package/dist/assertions/record/model.cjs.map +1 -1
- package/dist/assertions/record/model.d.cts +120 -13
- package/dist/assertions/record/model.d.mts +120 -13
- package/dist/assertions/record/model.d.ts +120 -13
- package/dist/assertions/record/model.js +2 -0
- package/dist/assertions/record/producer.cjs +70 -50
- package/dist/assertions/record/producer.cjs.map +1 -1
- package/dist/assertions/record/producer.d.cts +8 -7
- package/dist/assertions/record/producer.d.mts +8 -7
- package/dist/assertions/record/producer.d.ts +8 -7
- package/dist/assertions/runtime.cjs +49 -7
- package/dist/assertions/runtime.cjs.map +1 -1
- package/dist/cli/application.cjs +40 -0
- package/dist/cli/application.cjs.map +1 -0
- package/dist/cli/application.d.cts +129 -0
- package/dist/cli/application.d.mts +129 -0
- package/dist/cli/application.d.ts +129 -0
- package/dist/cli/application.js +24 -0
- package/dist/cli/application.js.map +1 -0
- package/dist/cli/bootstrap.cjs +10 -4
- package/dist/cli/bootstrap.cjs.map +1 -1
- package/dist/cli/node-application.cjs +123 -0
- package/dist/cli/node-application.cjs.map +1 -0
- package/dist/cli/node-application.d.cts +14 -0
- package/dist/cli/node-application.d.mts +14 -0
- package/dist/cli/node-application.d.ts +14 -0
- package/dist/cli/node-application.js +26 -0
- package/dist/cli/node-application.js.map +1 -0
- package/dist/cli/program.cjs +2807 -0
- package/dist/cli/program.cjs.map +1 -0
- package/dist/cli/program.d.cts +352 -0
- package/dist/cli/program.d.mts +352 -0
- package/dist/cli/program.d.ts +352 -0
- package/dist/cli/program.js +36 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/project-configuration.cjs +134 -0
- package/dist/cli/project-configuration.cjs.map +1 -0
- package/dist/cli/project-configuration.d.cts +64 -0
- package/dist/cli/project-configuration.d.mts +64 -0
- package/dist/cli/project-configuration.d.ts +64 -0
- package/dist/cli/project-configuration.js +22 -0
- package/dist/cli/project-configuration.js.map +1 -0
- package/dist/cli/record.cjs +20 -4
- package/dist/cli/record.cjs.map +1 -1
- package/dist/cli/record.d.cts +3 -3
- package/dist/cli/record.d.mts +3 -3
- package/dist/cli/record.d.ts +3 -3
- package/dist/cli.cjs +19 -3130
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +2 -148
- package/dist/cli.d.mts +2 -148
- package/dist/cli.d.ts +2 -148
- package/dist/cli.js +22 -30
- package/dist/context/assert-first.cjs +21 -15
- package/dist/context/assert-first.cjs.map +1 -1
- package/dist/context/assert-first.d.cts +1 -0
- package/dist/context/assert-first.d.mts +1 -0
- package/dist/context/assert-first.d.ts +1 -0
- package/dist/context/attempt-resources.cjs +13 -0
- package/dist/context/attempt-resources.cjs.map +1 -0
- package/dist/context/attempt-resources.d.cts +3 -0
- package/dist/context/attempt-resources.d.mts +3 -0
- package/dist/context/attempt-resources.d.ts +3 -0
- package/dist/context/attempt-resources.js +8 -0
- package/dist/context/attempt-resources.js.map +1 -0
- package/dist/context/session.cjs +4 -3
- package/dist/context/session.cjs.map +1 -1
- package/dist/context/session.d.cts +1 -0
- package/dist/context/session.d.mts +1 -0
- package/dist/context/session.d.ts +1 -0
- package/dist/eval/record/verdict.cjs +3 -2
- package/dist/eval/record/verdict.cjs.map +1 -1
- package/dist/experiment/host/index.cjs +1 -6
- package/dist/experiment/host/index.cjs.map +1 -1
- package/dist/experiment/host/index.d.cts +1 -0
- package/dist/experiment/host/index.d.mts +1 -0
- package/dist/experiment/host/index.d.ts +1 -0
- package/dist/load-config.cjs +13 -4
- package/dist/load-config.cjs.map +1 -1
- package/dist/load-config.d.cts +4 -3
- package/dist/load-config.d.mts +4 -3
- package/dist/load-config.d.ts +4 -3
- package/dist/load-config.js +4 -2
- package/dist/o11y/parsers/codex.cjs +29 -7
- package/dist/o11y/parsers/codex.cjs.map +1 -1
- package/dist/record/codec/core.d.cts +0 -2
- package/dist/record/codec/core.d.mts +0 -2
- package/dist/record/codec/core.d.ts +0 -2
- package/dist/record/codec/identifiers.cjs +2 -3
- package/dist/record/codec/identifiers.cjs.map +1 -1
- package/dist/record/codec/identifiers.d.cts +1 -2
- package/dist/record/codec/identifiers.d.mts +1 -2
- package/dist/record/codec/identifiers.d.ts +1 -2
- package/dist/record/codec/identifiers.js +10 -12
- package/dist/record/codec/index.js +42 -44
- package/dist/record/definition/attachment.cjs +1 -0
- package/dist/record/definition/attachment.cjs.map +1 -1
- package/dist/record/definition/attachment.d.cts +14 -0
- package/dist/record/definition/attachment.d.mts +14 -0
- package/dist/record/definition/attachment.d.ts +14 -0
- package/dist/record/family/assertions-v1.cjs +104 -0
- package/dist/record/family/assertions-v1.cjs.map +1 -0
- package/dist/record/family/assertions-v1.d.cts +2 -0
- package/dist/record/family/assertions-v1.d.mts +2 -0
- package/dist/record/family/assertions-v1.d.ts +2 -0
- package/dist/record/family/assertions-v1.js +6 -0
- package/dist/record/family/assertions-v1.js.map +1 -0
- package/dist/record/family/assertions.cjs +16 -5
- package/dist/record/family/assertions.cjs.map +1 -1
- package/dist/record/family/assertions.d.cts +510 -56
- package/dist/record/family/assertions.d.mts +510 -56
- package/dist/record/family/assertions.d.ts +510 -56
- package/dist/record/family/assertions.js +14 -10
- package/dist/record/family/catalog.cjs +17 -1
- package/dist/record/family/catalog.cjs.map +1 -1
- package/dist/record/family/catalog.d.cts +1292 -104
- package/dist/record/family/catalog.d.mts +1292 -104
- package/dist/record/family/catalog.d.ts +1292 -104
- package/dist/record/family/catalog.js +22 -20
- package/dist/record/family/index.js +144 -138
- package/dist/record/family/observability-v1.cjs +5 -0
- package/dist/record/family/observability-v1.cjs.map +1 -1
- package/dist/record/family/observability.cjs +1 -1
- package/dist/record/family/observability.cjs.map +1 -1
- package/dist/record/host/runtime.cjs +323 -173
- 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 +9 -7
- package/dist/record/host/types.d.mts +9 -7
- package/dist/record/host/types.d.ts +9 -7
- package/dist/record/model/core.cjs.map +1 -1
- package/dist/record/model/core.d.cts +1 -2
- package/dist/record/model/core.d.mts +1 -2
- package/dist/record/model/core.d.ts +1 -2
- package/dist/record/model/definition.cjs +1 -2
- package/dist/record/model/definition.cjs.map +1 -1
- package/dist/record/model/definition.d.cts +1 -7
- package/dist/record/model/definition.d.mts +1 -7
- package/dist/record/model/definition.d.ts +1 -7
- package/dist/record/model/identifiers.cjs +2 -3
- package/dist/record/model/identifiers.cjs.map +1 -1
- package/dist/record/model/identifiers.d.cts +1 -3
- package/dist/record/model/identifiers.d.mts +1 -3
- package/dist/record/model/identifiers.d.ts +1 -3
- package/dist/record/model/identifiers.js +36 -38
- package/dist/record/model/index.js +60 -62
- package/dist/record/platform/node.cjs +17 -7
- 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 +8 -3
- package/dist/record/platform/services.d.mts +8 -3
- package/dist/record/platform/services.d.ts +8 -3
- package/dist/record/reader/format.cjs +16 -65
- package/dist/record/reader/format.cjs.map +1 -1
- package/dist/record/reader/format.d.cts +5 -9
- package/dist/record/reader/format.d.mts +5 -9
- package/dist/record/reader/format.d.ts +5 -9
- package/dist/record/reader/index.js +10 -8
- package/dist/record/reader/runtime.cjs +63 -32
- package/dist/record/reader/runtime.cjs.map +1 -1
- package/dist/record/reader/runtime.d.cts +40 -4
- package/dist/record/reader/runtime.d.mts +40 -4
- package/dist/record/reader/runtime.d.ts +40 -4
- package/dist/record/reader/runtime.js +6 -4
- package/dist/report/assets/enhance.js +5 -5
- package/dist/report/assets/styles.css +190 -24
- package/dist/report/built-in/result-components.cjs +8 -5
- package/dist/report/built-in/result-components.cjs.map +1 -1
- package/dist/report/built-in/standard.cjs +3 -0
- package/dist/report/built-in/standard.cjs.map +1 -1
- package/dist/report/built-in/standard.d.cts +2 -0
- package/dist/report/built-in/standard.d.mts +2 -0
- package/dist/report/built-in/standard.d.ts +2 -0
- package/dist/report/client-dist/app.js +53 -0
- package/dist/report/components/attempt-detail/compute.cjs +108 -231
- package/dist/report/components/attempt-detail/compute.cjs.map +1 -1
- package/dist/report/components/attempt-detail/compute.d.cts +11 -45
- package/dist/report/components/attempt-detail/compute.d.mts +11 -45
- package/dist/report/components/attempt-detail/compute.d.ts +11 -45
- package/dist/report/components/attempt-detail/compute.js +2 -4
- package/dist/report/components/attempt-detail/content.cjs +4 -4
- package/dist/report/components/attempt-detail/content.cjs.map +1 -1
- package/dist/report/components/attempt-detail/validate.cjs +47 -4
- package/dist/report/components/attempt-detail/validate.cjs.map +1 -1
- package/dist/report/components/entity-lists/compute.cjs +9 -15
- package/dist/report/components/entity-lists/compute.cjs.map +1 -1
- package/dist/report/components/entity-lists/content.cjs +53 -40
- package/dist/report/components/entity-lists/content.cjs.map +1 -1
- package/dist/report/components/entity-lists/index.cjs +1 -3
- package/dist/report/components/entity-lists/index.cjs.map +1 -1
- package/dist/report/components/experiment-detail/compute.cjs +4 -6
- package/dist/report/components/experiment-detail/compute.cjs.map +1 -1
- package/dist/report/components/summaries/index.cjs +5 -1
- package/dist/report/components/summaries/index.cjs.map +1 -1
- package/dist/report/definition/cell.cjs +14 -7
- package/dist/report/definition/cell.cjs.map +1 -1
- package/dist/report/definition/cell.d.cts +4 -0
- package/dist/report/definition/cell.d.mts +4 -0
- package/dist/report/definition/cell.d.ts +4 -0
- package/dist/report/definition/primitives/assertion-evidence.cjs +96 -0
- package/dist/report/definition/primitives/assertion-evidence.cjs.map +1 -0
- package/dist/report/definition/primitives/assertion-evidence.d.cts +11 -0
- package/dist/report/definition/primitives/assertion-evidence.d.mts +11 -0
- package/dist/report/definition/primitives/assertion-evidence.d.ts +11 -0
- package/dist/report/definition/primitives/assertion-evidence.js +6 -0
- package/dist/report/definition/primitives/assertion-evidence.js.map +1 -0
- package/dist/report/definition/primitives/conversation.cjs +7 -0
- package/dist/report/definition/primitives/conversation.cjs.map +1 -1
- package/dist/report/definition/primitives/conversation.d.cts +2 -0
- package/dist/report/definition/primitives/conversation.d.mts +2 -0
- package/dist/report/definition/primitives/conversation.d.ts +2 -0
- package/dist/report/definition/primitives/turn-trace.cjs +53 -3
- package/dist/report/definition/primitives/turn-trace.cjs.map +1 -1
- package/dist/report/definition/primitives.cjs +14 -1
- package/dist/report/definition/primitives.cjs.map +1 -1
- package/dist/report/definition/report.cjs +16 -8
- package/dist/report/definition/report.cjs.map +1 -1
- package/dist/report/definition/report.d.cts +6 -0
- package/dist/report/definition/report.d.mts +6 -0
- package/dist/report/definition/report.d.ts +6 -0
- package/dist/report/definition/table-text.cjs +12 -3
- package/dist/report/definition/table-text.cjs.map +1 -1
- package/dist/report/definition/table-text.d.cts +6 -1
- package/dist/report/definition/table-text.d.mts +6 -1
- package/dist/report/definition/table-text.d.ts +6 -1
- package/dist/report/execution/model.cjs +6 -14
- package/dist/report/execution/model.cjs.map +1 -1
- package/dist/report/execution/model.d.cts +5 -10
- package/dist/report/execution/model.d.mts +5 -10
- package/dist/report/execution/model.d.ts +5 -10
- package/dist/report/execution/model.js +6 -6
- package/dist/report/execution/paths.cjs +0 -11
- package/dist/report/execution/paths.cjs.map +1 -1
- package/dist/report/execution/paths.d.cts +0 -1
- package/dist/report/execution/paths.d.mts +0 -1
- package/dist/report/execution/paths.d.ts +0 -1
- package/dist/report/execution/paths.js +6 -8
- package/dist/report/host/execute.cjs +13 -22
- package/dist/report/host/execute.cjs.map +1 -1
- package/dist/report/host/execute.d.cts +1 -4
- package/dist/report/host/execute.d.mts +1 -4
- package/dist/report/host/execute.d.ts +1 -4
- package/dist/report/host/from-record.cjs +3 -0
- package/dist/report/host/from-record.cjs.map +1 -1
- package/dist/report/host/from-record.d.cts +4 -1
- package/dist/report/host/from-record.d.mts +4 -1
- package/dist/report/host/from-record.d.ts +4 -1
- package/dist/report/host/site-assets.cjs +1 -2
- package/dist/report/host/site-assets.cjs.map +1 -1
- package/dist/report/host/site-assets.d.cts +0 -1
- package/dist/report/host/site-assets.d.mts +0 -1
- package/dist/report/host/site-assets.d.ts +0 -1
- package/dist/report/host/site-assets.js +2 -4
- package/dist/report/host/static.cjs +71 -346
- package/dist/report/host/static.cjs.map +1 -1
- package/dist/report/host/static.d.cts +1 -3
- package/dist/report/host/static.d.mts +1 -3
- package/dist/report/host/static.d.ts +1 -3
- package/dist/report/host/static.js +2 -2
- package/dist/report/host/view-session.cjs.map +1 -1
- package/dist/report/host/view-session.d.cts +1 -1
- package/dist/report/host/view-session.d.mts +1 -1
- package/dist/report/host/view-session.d.ts +1 -1
- package/dist/report/model/locale.cjs +1 -1
- package/dist/report/model/locale.cjs.map +1 -1
- package/dist/report/model/locale.d.cts +1 -1
- package/dist/report/model/locale.d.mts +1 -1
- package/dist/report/model/locale.d.ts +1 -1
- package/dist/report/model/pricing.cjs +2 -2
- package/dist/report/model/pricing.cjs.map +1 -1
- package/dist/report/react/enhance.js +5 -5
- package/dist/report/react/styles.css +190 -24
- package/dist/runner/adoption.cjs +4 -7
- package/dist/runner/adoption.cjs.map +1 -1
- package/dist/runner/attempt-resources.cjs +60 -0
- package/dist/runner/attempt-resources.cjs.map +1 -0
- package/dist/runner/attempt-resources.d.cts +13 -0
- package/dist/runner/attempt-resources.d.mts +13 -0
- package/dist/runner/attempt-resources.d.ts +13 -0
- package/dist/runner/attempt-resources.js +6 -0
- package/dist/runner/attempt-resources.js.map +1 -0
- package/dist/runner/attempt.cjs +37 -3
- package/dist/runner/attempt.cjs.map +1 -1
- package/dist/runner/feedback/failure.cjs +77 -2
- package/dist/runner/feedback/failure.cjs.map +1 -1
- package/dist/runner/feedback/failure.d.cts +2 -1
- package/dist/runner/feedback/failure.d.mts +2 -1
- package/dist/runner/feedback/failure.d.ts +2 -1
- package/dist/runner/project-current.cjs +2 -13
- package/dist/runner/project-current.cjs.map +1 -1
- package/dist/runner/project-current.d.cts +4 -2
- package/dist/runner/project-current.d.mts +4 -2
- package/dist/runner/project-current.d.ts +4 -2
- package/dist/runner/reporters/braintrust.cjs +7 -7
- package/dist/runner/reporters/braintrust.cjs.map +1 -1
- package/dist/runner/reuse-readback.cjs +3 -4
- package/dist/runner/reuse-readback.cjs.map +1 -1
- package/dist/runner/run.cjs +5 -2
- package/dist/runner/run.cjs.map +1 -1
- package/dist/sandbox/backend.cjs +32 -2
- package/dist/sandbox/backend.cjs.map +1 -1
- package/dist/sandbox/backend.d.cts +12 -1
- package/dist/sandbox/backend.d.mts +12 -1
- package/dist/sandbox/backend.d.ts +12 -1
- package/dist/sandbox/backend.js +28 -22
- package/dist/sandbox/docker.cjs +140 -0
- package/dist/sandbox/docker.cjs.map +1 -1
- package/dist/sandbox/docker.d.cts +3 -1
- package/dist/sandbox/docker.d.mts +3 -1
- package/dist/sandbox/docker.d.ts +3 -1
- package/dist/sandbox/e2b.cjs +42 -0
- package/dist/sandbox/e2b.cjs.map +1 -1
- package/dist/sandbox/e2b.d.cts +2 -0
- package/dist/sandbox/e2b.d.mts +2 -0
- package/dist/sandbox/e2b.d.ts +2 -0
- package/dist/sandbox/local.cjs +64 -0
- package/dist/sandbox/local.cjs.map +1 -1
- package/dist/sandbox/local.d.cts +3 -1
- package/dist/sandbox/local.d.mts +3 -1
- package/dist/sandbox/local.d.ts +3 -1
- package/dist/sandbox/managed-process.cjs +49 -0
- package/dist/sandbox/managed-process.cjs.map +1 -0
- package/dist/sandbox/managed-process.d.cts +11 -0
- package/dist/sandbox/managed-process.d.mts +11 -0
- package/dist/sandbox/managed-process.d.ts +11 -0
- package/dist/sandbox/managed-process.js +6 -0
- package/dist/sandbox/managed-process.js.map +1 -0
- package/dist/sandbox/types.cjs.map +1 -1
- package/dist/sandbox/types.d.cts +24 -0
- package/dist/sandbox/types.d.mts +24 -0
- package/dist/sandbox/types.d.ts +24 -0
- package/dist/sandbox/vercel.cjs +1 -0
- package/dist/sandbox/vercel.cjs.map +1 -1
- package/dist/sandbox/vercel.d.cts +1 -0
- package/dist/sandbox/vercel.d.mts +1 -0
- package/dist/sandbox/vercel.d.ts +1 -0
- package/dist/view/server.cjs +2 -37
- package/dist/view/server.cjs.map +1 -1
- package/dist/view/server.d.cts +0 -3
- package/dist/view/server.d.mts +0 -3
- package/dist/view/server.d.ts +0 -3
- package/docs-site/zh/reference/builtin-agents.mdx +7 -7
- package/docs-site/zh/reference/official-adapters.mdx +4 -4
- package/docs-site/zh/reference/report-components.mdx +2 -2
- package/docs-site/zh/tutorials/configuration.mdx +2 -2
- package/docs-site/zh/tutorials/deploy-report-site.mdx +24 -2
- package/docs-site/zh/tutorials/publish-report.mdx +4 -4
- package/docs-site/zh/tutorials/sandbox-agent.mdx +5 -5
- package/docs-site/zh/tutorials/theming.mdx +2 -2
- package/package.json +4 -6
- package/dist/record/migration/index.cjs +0 -5
- package/dist/record/migration/index.cjs.map +0 -1
- package/dist/record/migration/index.d.cts +0 -11
- package/dist/record/migration/index.d.mts +0 -11
- package/dist/record/migration/index.d.ts +0 -11
- package/dist/record/migration/index.js +0 -6
- package/dist/record/migration/index.js.map +0 -1
- package/dist/report/host/site-runtime.cjs +0 -92
- package/dist/report/host/site-runtime.cjs.map +0 -1
- package/dist/report/host/site-runtime.d.cts +0 -9
- package/dist/report/host/site-runtime.d.mts +0 -9
- package/dist/report/host/site-runtime.d.ts +0 -9
- package/dist/report/host/site-runtime.js +0 -10
- package/dist/report/host/site-runtime.js.map +0 -1
- package/dist/view/client-dist/app.css +0 -2
- package/dist/view/client-dist/app.js +0 -49
- package/dist/view/data.cjs +0 -3
- package/dist/view/data.cjs.map +0 -1
- package/dist/view/data.d.cts +0 -9
- package/dist/view/data.d.mts +0 -9
- package/dist/view/data.d.ts +0 -9
- package/dist/view/data.js +0 -4
- package/dist/view/data.js.map +0 -1
- package/dist/view/index.cjs +0 -24
- package/dist/view/index.cjs.map +0 -1
- package/dist/view/index.d.cts +0 -9
- package/dist/view/index.d.mts +0 -9
- package/dist/view/index.d.ts +0 -9
- package/dist/view/index.js +0 -28
- package/dist/view/index.js.map +0 -1
- package/dist/view/report-view-cache.cjs +0 -200
- package/dist/view/report-view-cache.cjs.map +0 -1
- package/dist/view/report-view-cache.d.cts +0 -67
- package/dist/view/report-view-cache.d.mts +0 -67
- package/dist/view/report-view-cache.d.ts +0 -67
- package/dist/view/report-view-cache.js +0 -8
- package/dist/view/report-view-cache.js.map +0 -1
- package/dist/view/shared/types.cjs +0 -3
- package/dist/view/shared/types.cjs.map +0 -1
- package/dist/view/shared/types.d.cts +0 -51
- package/dist/view/shared/types.d.mts +0 -51
- package/dist/view/shared/types.d.ts +0 -51
- package/dist/view/shared/types.js +0 -4
- package/dist/view/shared/types.js.map +0 -1
- package/dist/view/site.cjs +0 -32
- package/dist/view/site.cjs.map +0 -1
- package/dist/view/site.d.cts +0 -24
- package/dist/view/site.d.mts +0 -24
- package/dist/view/site.d.ts +0 -24
- package/dist/view/site.js +0 -8
- package/dist/view/site.js.map +0 -1
- package/dist/view/styles.css +0 -170
- package/dist/view/template.html +0 -17
|
@@ -43,48 +43,46 @@ const __niceevalExport19 = __niceevalCanonical["RecordFormatSchema"];
|
|
|
43
43
|
export { __niceevalExport19 as RecordFormatSchema };
|
|
44
44
|
const __niceevalExport20 = __niceevalCanonical["RecordIdSchema"];
|
|
45
45
|
export { __niceevalExport20 as RecordIdSchema };
|
|
46
|
-
const __niceevalExport21 = __niceevalCanonical["
|
|
47
|
-
export { __niceevalExport21 as
|
|
48
|
-
const __niceevalExport22 = __niceevalCanonical["
|
|
49
|
-
export { __niceevalExport22 as
|
|
50
|
-
const __niceevalExport23 = __niceevalCanonical["
|
|
51
|
-
export { __niceevalExport23 as
|
|
52
|
-
const __niceevalExport24 = __niceevalCanonical["
|
|
53
|
-
export { __niceevalExport24 as
|
|
54
|
-
const __niceevalExport25 = __niceevalCanonical["
|
|
55
|
-
export { __niceevalExport25 as
|
|
56
|
-
const __niceevalExport26 = __niceevalCanonical["
|
|
57
|
-
export { __niceevalExport26 as
|
|
58
|
-
const __niceevalExport27 = __niceevalCanonical["
|
|
59
|
-
export { __niceevalExport27 as
|
|
60
|
-
const __niceevalExport28 = __niceevalCanonical["
|
|
61
|
-
export { __niceevalExport28 as
|
|
62
|
-
const __niceevalExport29 = __niceevalCanonical["
|
|
63
|
-
export { __niceevalExport29 as
|
|
64
|
-
const __niceevalExport30 = __niceevalCanonical["
|
|
65
|
-
export { __niceevalExport30 as
|
|
66
|
-
const __niceevalExport31 = __niceevalCanonical["
|
|
67
|
-
export { __niceevalExport31 as
|
|
68
|
-
const __niceevalExport32 = __niceevalCanonical["
|
|
69
|
-
export { __niceevalExport32 as
|
|
70
|
-
const __niceevalExport33 = __niceevalCanonical["
|
|
71
|
-
export { __niceevalExport33 as
|
|
72
|
-
const __niceevalExport34 = __niceevalCanonical["
|
|
73
|
-
export { __niceevalExport34 as
|
|
74
|
-
const __niceevalExport35 = __niceevalCanonical["
|
|
75
|
-
export { __niceevalExport35 as
|
|
76
|
-
const __niceevalExport36 = __niceevalCanonical["
|
|
77
|
-
export { __niceevalExport36 as
|
|
78
|
-
const __niceevalExport37 = __niceevalCanonical["
|
|
79
|
-
export { __niceevalExport37 as
|
|
80
|
-
const __niceevalExport38 = __niceevalCanonical["
|
|
81
|
-
export { __niceevalExport38 as
|
|
82
|
-
const __niceevalExport39 = __niceevalCanonical["
|
|
83
|
-
export { __niceevalExport39 as
|
|
84
|
-
const __niceevalExport40 = __niceevalCanonical["
|
|
85
|
-
export { __niceevalExport40 as
|
|
86
|
-
const __niceevalExport41 = __niceevalCanonical["
|
|
87
|
-
export { __niceevalExport41 as
|
|
88
|
-
const __niceevalExport42 = __niceevalCanonical["encodeRunDocument"];
|
|
89
|
-
export { __niceevalExport42 as encodeRunDocument };
|
|
46
|
+
const __niceevalExport21 = __niceevalCanonical["RecordSlotIdentitySchema"];
|
|
47
|
+
export { __niceevalExport21 as RecordSlotIdentitySchema };
|
|
48
|
+
const __niceevalExport22 = __niceevalCanonical["RunContextCurrentSchema"];
|
|
49
|
+
export { __niceevalExport22 as RunContextCurrentSchema };
|
|
50
|
+
const __niceevalExport23 = __niceevalCanonical["RunCoreSchema"];
|
|
51
|
+
export { __niceevalExport23 as RunCoreSchema };
|
|
52
|
+
const __niceevalExport24 = __niceevalCanonical["RunDocumentSchema"];
|
|
53
|
+
export { __niceevalExport24 as RunDocumentSchema };
|
|
54
|
+
const __niceevalExport25 = __niceevalCanonical["RunIdSchema"];
|
|
55
|
+
export { __niceevalExport25 as RunIdSchema };
|
|
56
|
+
const __niceevalExport26 = __niceevalCanonical["Sha256DigestSchema"];
|
|
57
|
+
export { __niceevalExport26 as Sha256DigestSchema };
|
|
58
|
+
const __niceevalExport27 = __niceevalCanonical["SlotIdSchema"];
|
|
59
|
+
export { __niceevalExport27 as SlotIdSchema };
|
|
60
|
+
const __niceevalExport28 = __niceevalCanonical["SourceItemIdSchema"];
|
|
61
|
+
export { __niceevalExport28 as SourceItemIdSchema };
|
|
62
|
+
const __niceevalExport29 = __niceevalCanonical["UtcMillisSchema"];
|
|
63
|
+
export { __niceevalExport29 as UtcMillisSchema };
|
|
64
|
+
const __niceevalExport30 = __niceevalCanonical["decodeAttemptDocument"];
|
|
65
|
+
export { __niceevalExport30 as decodeAttemptDocument };
|
|
66
|
+
const __niceevalExport31 = __niceevalCanonical["decodeMemberDocument"];
|
|
67
|
+
export { __niceevalExport31 as decodeMemberDocument };
|
|
68
|
+
const __niceevalExport32 = __niceevalCanonical["decodeRecordAttachmentEnvelope"];
|
|
69
|
+
export { __niceevalExport32 as decodeRecordAttachmentEnvelope };
|
|
70
|
+
const __niceevalExport33 = __niceevalCanonical["decodeRecordCore"];
|
|
71
|
+
export { __niceevalExport33 as decodeRecordCore };
|
|
72
|
+
const __niceevalExport34 = __niceevalCanonical["decodeRecordDocument"];
|
|
73
|
+
export { __niceevalExport34 as decodeRecordDocument };
|
|
74
|
+
const __niceevalExport35 = __niceevalCanonical["decodeRunDocument"];
|
|
75
|
+
export { __niceevalExport35 as decodeRunDocument };
|
|
76
|
+
const __niceevalExport36 = __niceevalCanonical["encodeAttemptDocument"];
|
|
77
|
+
export { __niceevalExport36 as encodeAttemptDocument };
|
|
78
|
+
const __niceevalExport37 = __niceevalCanonical["encodeMemberDocument"];
|
|
79
|
+
export { __niceevalExport37 as encodeMemberDocument };
|
|
80
|
+
const __niceevalExport38 = __niceevalCanonical["encodeRecordAttachmentEnvelope"];
|
|
81
|
+
export { __niceevalExport38 as encodeRecordAttachmentEnvelope };
|
|
82
|
+
const __niceevalExport39 = __niceevalCanonical["encodeRecordCore"];
|
|
83
|
+
export { __niceevalExport39 as encodeRecordCore };
|
|
84
|
+
const __niceevalExport40 = __niceevalCanonical["encodeRecordDocument"];
|
|
85
|
+
export { __niceevalExport40 as encodeRecordDocument };
|
|
86
|
+
const __niceevalExport41 = __niceevalCanonical["encodeRunDocument"];
|
|
87
|
+
export { __niceevalExport41 as encodeRunDocument };
|
|
90
88
|
//# sourceMappingURL=index.js.map
|
|
@@ -73,6 +73,7 @@ function defineRecordAttachment(input) {
|
|
|
73
73
|
link.fromSchemaVersion <= 0 ||
|
|
74
74
|
link.toSchemaVersion !== link.fromSchemaVersion + 1 ||
|
|
75
75
|
link.toSchemaVersion > input.current.schemaVersion ||
|
|
76
|
+
typeof link.rewritePayload !== "boolean" ||
|
|
76
77
|
migrationStarts.has(link.fromSchemaVersion)) {
|
|
77
78
|
throw new TypeError("Record Attachment migration links must be unique adjacent upgrades to current history");
|
|
78
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["attachment.ts"],"names":[],"mappings":";;AAyGA,8EAEC;AAKD,wDAyDC;AAxKD,2DAAsG;AAGtG,uDAA+G;AAC/G,MAAM,qCAAqC,GAAkB,MAAM,CAAC,kDAAkD,CAAC,CAAC;AACxH,MAAM,cAAc,GAAG,IAAI,OAAO,EAAU,CAAC;AA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AAG,CAAC,CAAC;QAC/B,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,SAAS,CAAC,+DAA+D,CAAC,CAAC;QACzF,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;YACnB,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,aAAa;YAC1C,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAA6C;SAC9E,CAAC;QACF,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,sBAAsB,EAAE,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;KAC1G,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Schema } from \"effect\";\nimport { RecordBlobRefSchema, isRecordBlobRef, type RecordBlobRef, } from \"../attachment/blob-ref.ts\";\nimport type { RecordAttachmentBlobBudget, RecordAttachmentBlobRefs, RecordAttachmentMaterializedRefine, } from \"../attachment/blob-policy.ts\";\nimport type { RecordAttachmentOwner } from \"../model/core.ts\";\nimport { compileRecordSchemaCodec, type RecordSchemaCodec, type RecordSchemaLimits, } from \"./schema-codec.ts\";\nconst recordAttachmentOwnerDefinitionTypeId: unique symbol = Symbol(\"@niceeval/record/RecordAttachmentOwnerDefinition\");\nconst compiledOwners = new WeakSet<object>();\nexport type { RecordAttachmentOwner } from \"../model/core.ts\";\nexport interface RecordAttachmentOwnerInput<SourceSchema extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext> {\n readonly schema: SourceSchema;\n readonly limits: RecordSchemaLimits;\n readonly blobs: Readonly<{\n readonly refs: RecordAttachmentBlobRefs<Schema.Schema.Type<SourceSchema>>;\n readonly budget: RecordAttachmentBlobBudget;\n readonly verify: RecordAttachmentMaterializedRefine<Schema.Schema.Type<SourceSchema>>;\n }>;\n}\nexport type RecordAttachmentOwnerInputs = Readonly<Partial<Record<RecordAttachmentOwner, RecordAttachmentOwnerInput<Schema.Schema.AnyNoContext>>>>;\n/** One owner compiled exactly once from a fixed family declaration. */\nexport interface RecordAttachmentOwnerDefinition<Owner extends RecordAttachmentOwner, Payload, SourceSchema extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext> {\n readonly family: string;\n readonly schemaVersion: number;\n readonly owner: Owner;\n readonly codec: RecordSchemaCodec<Payload, RecordBlobRef, SourceSchema>;\n readonly refs: RecordAttachmentBlobRefs<Payload>;\n readonly budget: RecordAttachmentBlobBudget;\n readonly verify: RecordAttachmentMaterializedRefine<Payload>;\n readonly [recordAttachmentOwnerDefinitionTypeId]: () => void;\n}\ntype OwnerDefinitionFor<Owner extends RecordAttachmentOwner, Input> = Input extends RecordAttachmentOwnerInput<infer SourceSchema> ? RecordAttachmentOwnerDefinition<Owner, Schema.Schema.Type<SourceSchema>, SourceSchema> : never;\nexport type RecordAttachmentOwnerDefinitions<Owners extends RecordAttachmentOwnerInputs> = Readonly<{\n readonly [Owner in keyof Owners]: Owner extends RecordAttachmentOwner ? OwnerDefinitionFor<Owner, Owners[Owner]> : never;\n}>;\n/** Historical codecs stay opaque to the current import graph until maintenance asks for them. */\nexport interface RecordAttachmentHistoricalCodec {\n readonly schemaVersion: number;\n readonly decode: (input: unknown) => unknown;\n}\n/** Only adjacent, package-owned migrations may be declared for a fixed family. */\nexport interface RecordAttachmentAdjacentMigration {\n readonly fromSchemaVersion: number;\n readonly toSchemaVersion: number;\n readonly migrate: (input: unknown) => unknown;\n}\n/** Eager metadata only: implementation remains behind `maintenance`. */\nexport interface RecordAttachmentAdjacentMigrationLink {\n readonly fromSchemaVersion: number;\n readonly toSchemaVersion: number;\n}\nexport interface RecordAttachmentMaintenanceFacet {\n /** Historical codecs and adjacent migrations remain behind this lazy boundary. */\n readonly historicalCodecs: readonly RecordAttachmentHistoricalCodec[];\n readonly adjacentMigrations: readonly RecordAttachmentAdjacentMigration[];\n}\nexport interface RecordAttachmentDefinition<out Family extends string = string, Owners extends RecordAttachmentOwnerInputs = RecordAttachmentOwnerInputs> {\n readonly family: Family;\n readonly current: Readonly<{\n readonly schemaVersion: number;\n readonly owners: RecordAttachmentOwnerDefinitions<Owners>;\n }>;\n readonly maintenance: (() => Promise<RecordAttachmentMaintenanceFacet>) | undefined;\n readonly adjacentMigrationLinks: readonly RecordAttachmentAdjacentMigrationLink[];\n}\nfunction validFamily(value: string): boolean {\n return /^niceeval\\.[a-z0-9][a-z0-9.-]*$/.test(value) && !value.includes(\"/\");\n}\nfunction validBlobBudget(value: unknown): value is RecordAttachmentBlobBudget {\n if (typeof value !== \"object\" || value === null)\n return false;\n const budget = value as Record<string, unknown>;\n return [budget.maximumBlobs, budget.maximumBlobBytes, budget.maximumTotalBytes]\n .every((limit) => Number.isSafeInteger(limit) && (limit as number) > 0);\n}\nfunction compileOwner<Owner extends RecordAttachmentOwner, SourceSchema extends Schema.Schema.AnyNoContext>(family: string, schemaVersion: number, owner: Owner, input: RecordAttachmentOwnerInput<SourceSchema>): RecordAttachmentOwnerDefinition<Owner, Schema.Schema.Type<SourceSchema>, SourceSchema> {\n if (typeof input !== \"object\" ||\n input === null ||\n typeof input.blobs !== \"object\" ||\n input.blobs === null ||\n typeof input.blobs.refs !== \"function\" ||\n !validBlobBudget(input.blobs.budget) ||\n typeof input.blobs.verify !== \"function\") {\n throw new TypeError(\"Record Attachment owners must declare a bounded blob policy\");\n }\n const codec = compileRecordSchemaCodec({\n schema: input.schema,\n limits: input.limits,\n blobRef: {\n schema: RecordBlobRefSchema,\n isBlobRef: isRecordBlobRef,\n },\n });\n const definition: RecordAttachmentOwnerDefinition<Owner, Schema.Schema.Type<SourceSchema>, SourceSchema> = {\n family,\n schemaVersion,\n owner,\n codec,\n refs: input.blobs.refs,\n budget: Object.freeze({ ...input.blobs.budget }),\n verify: input.blobs.verify,\n [recordAttachmentOwnerDefinitionTypeId]: () => undefined,\n };\n compiledOwners.add(definition);\n return Object.freeze(definition);\n}\n/** @internal Runtime factories accept only owners minted by defineRecordAttachment. */\nexport function isRecordAttachmentOwnerDefinition(value: unknown): value is RecordAttachmentOwnerDefinition<RecordAttachmentOwner, unknown> {\n return typeof value === \"object\" && value !== null && compiledOwners.has(value);\n}\n/**\n * NiceEval-only fixed-family declaration. It stores no registry and exposes no\n * plugin hook: the static catalog is assembled by package code alone.\n */\nexport function defineRecordAttachment<const Family extends string, const Owners extends RecordAttachmentOwnerInputs>(input: {\n readonly family: Family;\n readonly current: {\n readonly schemaVersion: number;\n readonly owners: Owners;\n };\n readonly maintenance?: () => Promise<RecordAttachmentMaintenanceFacet>;\n readonly adjacentMigrationLinks?: readonly RecordAttachmentAdjacentMigrationLink[];\n}): RecordAttachmentDefinition<Family, Owners> {\n if (!validFamily(input.family)) {\n throw new TypeError(\"Record Attachment family must be a stable niceeval.* identity without a version suffix\");\n }\n if (!Number.isSafeInteger(input.current.schemaVersion) || input.current.schemaVersion <= 0) {\n throw new TypeError(\"Record Attachment schemaVersion must be a positive safe integer\");\n }\n if (input.maintenance !== undefined && typeof input.maintenance !== \"function\") {\n throw new TypeError(\"Record Attachment maintenance must be a lazy function\");\n }\n const adjacentMigrationLinks = input.adjacentMigrationLinks ?? Object.freeze([]);\n const migrationStarts = new Set<number>();\n for (const link of adjacentMigrationLinks) {\n if (!Number.isSafeInteger(link.fromSchemaVersion) ||\n !Number.isSafeInteger(link.toSchemaVersion) ||\n link.fromSchemaVersion <= 0 ||\n link.toSchemaVersion !== link.fromSchemaVersion + 1 ||\n link.toSchemaVersion > input.current.schemaVersion ||\n migrationStarts.has(link.fromSchemaVersion)) {\n throw new TypeError(\"Record Attachment migration links must be unique adjacent upgrades to current history\");\n }\n migrationStarts.add(link.fromSchemaVersion);\n }\n if (adjacentMigrationLinks.length > 0 && input.maintenance === undefined) {\n throw new TypeError(\"Record Attachment migration links require a lazy maintenance implementation\");\n }\n const keys = Reflect.ownKeys(input.current.owners);\n if (keys.length === 0 ||\n keys.some((key) => key !== \"attempt\" && key !== \"run\")) {\n throw new TypeError(\"Record Attachment owners may contain only attempt and run\");\n }\n const owners = input.current.owners as RecordAttachmentOwnerInputs;\n const compiled: Partial<Record<RecordAttachmentOwner, RecordAttachmentOwnerDefinition<RecordAttachmentOwner, unknown>>> = {};\n for (const key of keys as readonly RecordAttachmentOwner[]) {\n const ownerInput = owners[key];\n if (ownerInput === undefined) {\n throw new TypeError(\"Record Attachment owners must have one schema and blob policy\");\n }\n compiled[key] = compileOwner(input.family, input.current.schemaVersion, key, ownerInput);\n }\n return Object.freeze({\n family: input.family,\n current: Object.freeze({\n schemaVersion: input.current.schemaVersion,\n owners: Object.freeze(compiled) as RecordAttachmentOwnerDefinitions<Owners>,\n }),\n maintenance: input.maintenance,\n adjacentMigrationLinks: Object.freeze(adjacentMigrationLinks.map((link) => Object.freeze({ ...link }))),\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["attachment.ts"],"names":[],"mappings":";;AAuHA,8EAEC;AAKD,wDA0DC;AAvLD,2DAAsG;AAGtG,uDAA+G;AAC/G,MAAM,qCAAqC,GAAkB,MAAM,CAAC,kDAAkD,CAAC,CAAC;AACxH,MAAM,cAAc,GAAG,IAAI,OAAO,EAAU,CAAC;AAuE7C,SAAS,WAAW,CAAC,KAAa;IAC9B,OAAO,iCAAiC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AACjF,CAAC;AACD,SAAS,eAAe,CAAC,KAAc;IACnC,IAAI,OAAO,KAAK,KAAK,QAAQ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,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;YACnB,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,aAAa;YAC1C,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAA6C;SAC9E,CAAC;QACF,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,sBAAsB,EAAE,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;KAC1G,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Schema } from \"effect\";\nimport { RecordBlobRefSchema, isRecordBlobRef, type RecordBlobRef, } from \"../attachment/blob-ref.ts\";\nimport type { RecordAttachmentBlobBudget, RecordAttachmentBlobRefs, RecordAttachmentMaterializedRefine, } from \"../attachment/blob-policy.ts\";\nimport type { RecordAttachmentOwner } from \"../model/core.ts\";\nimport { compileRecordSchemaCodec, type RecordSchemaCodec, type RecordSchemaLimits, } from \"./schema-codec.ts\";\nconst recordAttachmentOwnerDefinitionTypeId: unique symbol = Symbol(\"@niceeval/record/RecordAttachmentOwnerDefinition\");\nconst compiledOwners = new WeakSet<object>();\nexport type { RecordAttachmentOwner } from \"../model/core.ts\";\nexport interface RecordAttachmentOwnerInput<SourceSchema extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext> {\n readonly schema: SourceSchema;\n readonly limits: RecordSchemaLimits;\n readonly blobs: Readonly<{\n readonly refs: RecordAttachmentBlobRefs<Schema.Schema.Type<SourceSchema>>;\n readonly budget: RecordAttachmentBlobBudget;\n readonly verify: RecordAttachmentMaterializedRefine<Schema.Schema.Type<SourceSchema>>;\n }>;\n}\nexport type RecordAttachmentOwnerInputs = Readonly<Partial<Record<RecordAttachmentOwner, RecordAttachmentOwnerInput<Schema.Schema.AnyNoContext>>>>;\n/** One owner compiled exactly once from a fixed family declaration. */\nexport interface RecordAttachmentOwnerDefinition<Owner extends RecordAttachmentOwner, Payload, SourceSchema extends Schema.Schema.AnyNoContext = Schema.Schema.AnyNoContext> {\n readonly family: string;\n readonly schemaVersion: number;\n readonly owner: Owner;\n readonly codec: RecordSchemaCodec<Payload, RecordBlobRef, SourceSchema>;\n readonly refs: RecordAttachmentBlobRefs<Payload>;\n readonly budget: RecordAttachmentBlobBudget;\n readonly verify: RecordAttachmentMaterializedRefine<Payload>;\n readonly [recordAttachmentOwnerDefinitionTypeId]: () => void;\n}\ntype OwnerDefinitionFor<Owner extends RecordAttachmentOwner, Input> = Input extends RecordAttachmentOwnerInput<infer SourceSchema> ? RecordAttachmentOwnerDefinition<Owner, Schema.Schema.Type<SourceSchema>, SourceSchema> : never;\nexport type RecordAttachmentOwnerDefinitions<Owners extends RecordAttachmentOwnerInputs> = Readonly<{\n readonly [Owner in keyof Owners]: Owner extends RecordAttachmentOwner ? OwnerDefinitionFor<Owner, Owners[Owner]> : never;\n}>;\n/** Historical codecs stay opaque to the current import graph until maintenance asks for them. */\nexport interface RecordAttachmentHistoricalCodec {\n readonly schemaVersion: number;\n readonly decode: (input: unknown) => unknown;\n /** Optional historical own-blob integrity check, run before a lossy transform. */\n readonly verify?: (payload: unknown, blobs: readonly {\n readonly ref: RecordBlobRef;\n readonly bytes: Uint8Array;\n }[]) => boolean;\n}\n/** Only adjacent, package-owned migrations may be declared for a fixed family. */\nexport interface RecordAttachmentAdjacentMigration {\n readonly fromSchemaVersion: number;\n readonly toSchemaVersion: number;\n /** User-visible semantic impact shared by plan and receipt surfaces. */\n readonly retention: RecordAttachmentMigrationRetention;\n readonly migrate: (input: unknown) => unknown;\n}\nexport interface RecordAttachmentMigrationRetention {\n readonly retainedFacts: readonly string[];\n readonly droppedFacts: readonly string[];\n readonly rerunRecommendation: string | null;\n}\n/** Eager metadata only: implementation remains behind `maintenance`. */\nexport interface RecordAttachmentAdjacentMigrationLink {\n readonly fromSchemaVersion: number;\n readonly toSchemaVersion: number;\n /** Physical plan metadata shared by planning, execution, and interrupted recovery. */\n readonly rewritePayload: boolean;\n}\nexport interface RecordAttachmentMaintenanceFacet {\n /** Historical codecs and adjacent migrations remain behind this lazy boundary. */\n readonly historicalCodecs: readonly RecordAttachmentHistoricalCodec[];\n readonly adjacentMigrations: readonly RecordAttachmentAdjacentMigration[];\n}\nexport interface RecordAttachmentDefinition<out Family extends string = string, Owners extends RecordAttachmentOwnerInputs = RecordAttachmentOwnerInputs> {\n readonly family: Family;\n readonly current: Readonly<{\n readonly schemaVersion: number;\n readonly owners: RecordAttachmentOwnerDefinitions<Owners>;\n }>;\n readonly maintenance: (() => Promise<RecordAttachmentMaintenanceFacet>) | undefined;\n readonly adjacentMigrationLinks: readonly RecordAttachmentAdjacentMigrationLink[];\n}\nfunction validFamily(value: string): boolean {\n return /^niceeval\\.[a-z0-9][a-z0-9.-]*$/.test(value) && !value.includes(\"/\");\n}\nfunction validBlobBudget(value: unknown): value is RecordAttachmentBlobBudget {\n if (typeof value !== \"object\" || value === null)\n return false;\n const budget = value as Record<string, unknown>;\n return [budget.maximumBlobs, budget.maximumBlobBytes, budget.maximumTotalBytes]\n .every((limit) => Number.isSafeInteger(limit) && (limit as number) > 0);\n}\nfunction compileOwner<Owner extends RecordAttachmentOwner, SourceSchema extends Schema.Schema.AnyNoContext>(family: string, schemaVersion: number, owner: Owner, input: RecordAttachmentOwnerInput<SourceSchema>): RecordAttachmentOwnerDefinition<Owner, Schema.Schema.Type<SourceSchema>, SourceSchema> {\n if (typeof input !== \"object\" ||\n input === null ||\n typeof input.blobs !== \"object\" ||\n input.blobs === null ||\n typeof input.blobs.refs !== \"function\" ||\n !validBlobBudget(input.blobs.budget) ||\n typeof input.blobs.verify !== \"function\") {\n throw new TypeError(\"Record Attachment owners must declare a bounded blob policy\");\n }\n const codec = compileRecordSchemaCodec({\n schema: input.schema,\n limits: input.limits,\n blobRef: {\n schema: RecordBlobRefSchema,\n isBlobRef: isRecordBlobRef,\n },\n });\n const definition: RecordAttachmentOwnerDefinition<Owner, Schema.Schema.Type<SourceSchema>, SourceSchema> = {\n family,\n schemaVersion,\n owner,\n codec,\n refs: input.blobs.refs,\n budget: Object.freeze({ ...input.blobs.budget }),\n verify: input.blobs.verify,\n [recordAttachmentOwnerDefinitionTypeId]: () => undefined,\n };\n compiledOwners.add(definition);\n return Object.freeze(definition);\n}\n/** @internal Runtime factories accept only owners minted by defineRecordAttachment. */\nexport function isRecordAttachmentOwnerDefinition(value: unknown): value is RecordAttachmentOwnerDefinition<RecordAttachmentOwner, unknown> {\n return typeof value === \"object\" && value !== null && compiledOwners.has(value);\n}\n/**\n * NiceEval-only fixed-family declaration. It stores no registry and exposes no\n * plugin hook: the static catalog is assembled by package code alone.\n */\nexport function defineRecordAttachment<const Family extends string, const Owners extends RecordAttachmentOwnerInputs>(input: {\n readonly family: Family;\n readonly current: {\n readonly schemaVersion: number;\n readonly owners: Owners;\n };\n readonly maintenance?: () => Promise<RecordAttachmentMaintenanceFacet>;\n readonly adjacentMigrationLinks?: readonly RecordAttachmentAdjacentMigrationLink[];\n}): RecordAttachmentDefinition<Family, Owners> {\n if (!validFamily(input.family)) {\n throw new TypeError(\"Record Attachment family must be a stable niceeval.* identity without a version suffix\");\n }\n if (!Number.isSafeInteger(input.current.schemaVersion) || input.current.schemaVersion <= 0) {\n throw new TypeError(\"Record Attachment schemaVersion must be a positive safe integer\");\n }\n if (input.maintenance !== undefined && typeof input.maintenance !== \"function\") {\n throw new TypeError(\"Record Attachment maintenance must be a lazy function\");\n }\n const adjacentMigrationLinks = input.adjacentMigrationLinks ?? Object.freeze([]);\n const migrationStarts = new Set<number>();\n for (const link of adjacentMigrationLinks) {\n if (!Number.isSafeInteger(link.fromSchemaVersion) ||\n !Number.isSafeInteger(link.toSchemaVersion) ||\n link.fromSchemaVersion <= 0 ||\n link.toSchemaVersion !== link.fromSchemaVersion + 1 ||\n link.toSchemaVersion > input.current.schemaVersion ||\n typeof link.rewritePayload !== \"boolean\" ||\n migrationStarts.has(link.fromSchemaVersion)) {\n throw new TypeError(\"Record Attachment migration links must be unique adjacent upgrades to current history\");\n }\n migrationStarts.add(link.fromSchemaVersion);\n }\n if (adjacentMigrationLinks.length > 0 && input.maintenance === undefined) {\n throw new TypeError(\"Record Attachment migration links require a lazy maintenance implementation\");\n }\n const keys = Reflect.ownKeys(input.current.owners);\n if (keys.length === 0 ||\n keys.some((key) => key !== \"attempt\" && key !== \"run\")) {\n throw new TypeError(\"Record Attachment owners may contain only attempt and run\");\n }\n const owners = input.current.owners as RecordAttachmentOwnerInputs;\n const compiled: Partial<Record<RecordAttachmentOwner, RecordAttachmentOwnerDefinition<RecordAttachmentOwner, unknown>>> = {};\n for (const key of keys as readonly RecordAttachmentOwner[]) {\n const ownerInput = owners[key];\n if (ownerInput === undefined) {\n throw new TypeError(\"Record Attachment owners must have one schema and blob policy\");\n }\n compiled[key] = compileOwner(input.family, input.current.schemaVersion, key, ownerInput);\n }\n return Object.freeze({\n family: input.family,\n current: Object.freeze({\n schemaVersion: input.current.schemaVersion,\n owners: Object.freeze(compiled) as RecordAttachmentOwnerDefinitions<Owners>,\n }),\n maintenance: input.maintenance,\n adjacentMigrationLinks: Object.freeze(adjacentMigrationLinks.map((link) => Object.freeze({ ...link }))),\n });\n}\n"]}
|
|
@@ -34,17 +34,31 @@ export type RecordAttachmentOwnerDefinitions<Owners extends RecordAttachmentOwne
|
|
|
34
34
|
export interface RecordAttachmentHistoricalCodec {
|
|
35
35
|
readonly schemaVersion: number;
|
|
36
36
|
readonly decode: (input: unknown) => unknown;
|
|
37
|
+
/** Optional historical own-blob integrity check, run before a lossy transform. */
|
|
38
|
+
readonly verify?: (payload: unknown, blobs: readonly {
|
|
39
|
+
readonly ref: RecordBlobRef;
|
|
40
|
+
readonly bytes: Uint8Array;
|
|
41
|
+
}[]) => boolean;
|
|
37
42
|
}
|
|
38
43
|
/** Only adjacent, package-owned migrations may be declared for a fixed family. */
|
|
39
44
|
export interface RecordAttachmentAdjacentMigration {
|
|
40
45
|
readonly fromSchemaVersion: number;
|
|
41
46
|
readonly toSchemaVersion: number;
|
|
47
|
+
/** User-visible semantic impact shared by plan and receipt surfaces. */
|
|
48
|
+
readonly retention: RecordAttachmentMigrationRetention;
|
|
42
49
|
readonly migrate: (input: unknown) => unknown;
|
|
43
50
|
}
|
|
51
|
+
export interface RecordAttachmentMigrationRetention {
|
|
52
|
+
readonly retainedFacts: readonly string[];
|
|
53
|
+
readonly droppedFacts: readonly string[];
|
|
54
|
+
readonly rerunRecommendation: string | null;
|
|
55
|
+
}
|
|
44
56
|
/** Eager metadata only: implementation remains behind `maintenance`. */
|
|
45
57
|
export interface RecordAttachmentAdjacentMigrationLink {
|
|
46
58
|
readonly fromSchemaVersion: number;
|
|
47
59
|
readonly toSchemaVersion: number;
|
|
60
|
+
/** Physical plan metadata shared by planning, execution, and interrupted recovery. */
|
|
61
|
+
readonly rewritePayload: boolean;
|
|
48
62
|
}
|
|
49
63
|
export interface RecordAttachmentMaintenanceFacet {
|
|
50
64
|
/** Historical codecs and adjacent migrations remain behind this lazy boundary. */
|
|
@@ -34,17 +34,31 @@ export type RecordAttachmentOwnerDefinitions<Owners extends RecordAttachmentOwne
|
|
|
34
34
|
export interface RecordAttachmentHistoricalCodec {
|
|
35
35
|
readonly schemaVersion: number;
|
|
36
36
|
readonly decode: (input: unknown) => unknown;
|
|
37
|
+
/** Optional historical own-blob integrity check, run before a lossy transform. */
|
|
38
|
+
readonly verify?: (payload: unknown, blobs: readonly {
|
|
39
|
+
readonly ref: RecordBlobRef;
|
|
40
|
+
readonly bytes: Uint8Array;
|
|
41
|
+
}[]) => boolean;
|
|
37
42
|
}
|
|
38
43
|
/** Only adjacent, package-owned migrations may be declared for a fixed family. */
|
|
39
44
|
export interface RecordAttachmentAdjacentMigration {
|
|
40
45
|
readonly fromSchemaVersion: number;
|
|
41
46
|
readonly toSchemaVersion: number;
|
|
47
|
+
/** User-visible semantic impact shared by plan and receipt surfaces. */
|
|
48
|
+
readonly retention: RecordAttachmentMigrationRetention;
|
|
42
49
|
readonly migrate: (input: unknown) => unknown;
|
|
43
50
|
}
|
|
51
|
+
export interface RecordAttachmentMigrationRetention {
|
|
52
|
+
readonly retainedFacts: readonly string[];
|
|
53
|
+
readonly droppedFacts: readonly string[];
|
|
54
|
+
readonly rerunRecommendation: string | null;
|
|
55
|
+
}
|
|
44
56
|
/** Eager metadata only: implementation remains behind `maintenance`. */
|
|
45
57
|
export interface RecordAttachmentAdjacentMigrationLink {
|
|
46
58
|
readonly fromSchemaVersion: number;
|
|
47
59
|
readonly toSchemaVersion: number;
|
|
60
|
+
/** Physical plan metadata shared by planning, execution, and interrupted recovery. */
|
|
61
|
+
readonly rewritePayload: boolean;
|
|
48
62
|
}
|
|
49
63
|
export interface RecordAttachmentMaintenanceFacet {
|
|
50
64
|
/** Historical codecs and adjacent migrations remain behind this lazy boundary. */
|
|
@@ -34,17 +34,31 @@ export type RecordAttachmentOwnerDefinitions<Owners extends RecordAttachmentOwne
|
|
|
34
34
|
export interface RecordAttachmentHistoricalCodec {
|
|
35
35
|
readonly schemaVersion: number;
|
|
36
36
|
readonly decode: (input: unknown) => unknown;
|
|
37
|
+
/** Optional historical own-blob integrity check, run before a lossy transform. */
|
|
38
|
+
readonly verify?: (payload: unknown, blobs: readonly {
|
|
39
|
+
readonly ref: RecordBlobRef;
|
|
40
|
+
readonly bytes: Uint8Array;
|
|
41
|
+
}[]) => boolean;
|
|
37
42
|
}
|
|
38
43
|
/** Only adjacent, package-owned migrations may be declared for a fixed family. */
|
|
39
44
|
export interface RecordAttachmentAdjacentMigration {
|
|
40
45
|
readonly fromSchemaVersion: number;
|
|
41
46
|
readonly toSchemaVersion: number;
|
|
47
|
+
/** User-visible semantic impact shared by plan and receipt surfaces. */
|
|
48
|
+
readonly retention: RecordAttachmentMigrationRetention;
|
|
42
49
|
readonly migrate: (input: unknown) => unknown;
|
|
43
50
|
}
|
|
51
|
+
export interface RecordAttachmentMigrationRetention {
|
|
52
|
+
readonly retainedFacts: readonly string[];
|
|
53
|
+
readonly droppedFacts: readonly string[];
|
|
54
|
+
readonly rerunRecommendation: string | null;
|
|
55
|
+
}
|
|
44
56
|
/** Eager metadata only: implementation remains behind `maintenance`. */
|
|
45
57
|
export interface RecordAttachmentAdjacentMigrationLink {
|
|
46
58
|
readonly fromSchemaVersion: number;
|
|
47
59
|
readonly toSchemaVersion: number;
|
|
60
|
+
/** Physical plan metadata shared by planning, execution, and interrupted recovery. */
|
|
61
|
+
readonly rewritePayload: boolean;
|
|
48
62
|
}
|
|
49
63
|
export interface RecordAttachmentMaintenanceFacet {
|
|
50
64
|
/** Historical codecs and adjacent migrations remain behind this lazy boundary. */
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertionsV1Maintenance = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const effect_1 = require("effect");
|
|
6
|
+
const core_ts_1 = require("../codec/core.cjs");
|
|
7
|
+
const assertions_ts_1 = require("./assertions.cjs");
|
|
8
|
+
function parseAssertionsV1(value) {
|
|
9
|
+
const decoded = effect_1.Schema.decodeUnknownEither(assertions_ts_1.AssertionsAttachmentV1Schema, core_ts_1.RecordExactParseOptions)(value);
|
|
10
|
+
if (effect_1.Either.isLeft(decoded))
|
|
11
|
+
throw new Error("Assertions v1 payload is invalid");
|
|
12
|
+
return decoded.right;
|
|
13
|
+
}
|
|
14
|
+
function decodeAssertionsV1(value) {
|
|
15
|
+
parseAssertionsV1(value);
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
/** Pure adjacent payload transform. Record maintenance exclusively owns physical I/O. */
|
|
19
|
+
function migrateAssertionsV1(value) {
|
|
20
|
+
const previous = parseAssertionsV1(value);
|
|
21
|
+
const migrated = Object.freeze({
|
|
22
|
+
"entries-data": Object.freeze(previous.entries.map((entry) => Object.freeze({
|
|
23
|
+
entryId: entry.entryId,
|
|
24
|
+
display: entry.display,
|
|
25
|
+
criterion: Object.freeze({ state: "unavailable", reason: "not-recorded" }),
|
|
26
|
+
materials: Object.freeze({
|
|
27
|
+
source: Object.freeze({ kind: "unavailable", reason: "not-recorded" }),
|
|
28
|
+
evidence: Object.freeze([]),
|
|
29
|
+
coverage: Object.freeze({ state: "unavailable", reason: "not-collected" }),
|
|
30
|
+
limitations: Object.freeze([]),
|
|
31
|
+
}),
|
|
32
|
+
evaluation: Object.freeze({
|
|
33
|
+
observed: Object.freeze({ kind: "unavailable", reason: "not-recorded" }),
|
|
34
|
+
}),
|
|
35
|
+
decision: Object.freeze({
|
|
36
|
+
result: entry.result.state,
|
|
37
|
+
reason: "reason" in entry.result ? entry.result.reason : null,
|
|
38
|
+
gate: entry.result.gate,
|
|
39
|
+
}),
|
|
40
|
+
policy: Object.freeze({
|
|
41
|
+
requirement: entry.result.gate === "not-gate"
|
|
42
|
+
? Object.freeze({ state: "unavailable", reason: "not-recorded" })
|
|
43
|
+
: Object.freeze({ state: "available", value: "required" }),
|
|
44
|
+
condition: Object.freeze({ state: "unavailable", reason: "not-recorded" }),
|
|
45
|
+
}),
|
|
46
|
+
contribution: entry.result.score,
|
|
47
|
+
explanationRetention: Object.freeze({ state: "unavailable", reason: "not-recorded" }),
|
|
48
|
+
}))),
|
|
49
|
+
"source-sites-data": previous.sourceSites,
|
|
50
|
+
});
|
|
51
|
+
const decoded = effect_1.Schema.decodeUnknownEither(assertions_ts_1.AssertionsAttachmentSchema, core_ts_1.RecordExactParseOptions)(migrated);
|
|
52
|
+
if (effect_1.Either.isLeft(decoded)) {
|
|
53
|
+
throw new Error(`Assertions v1 migration did not produce a current payload: ${effect_1.ParseResult.TreeFormatter.formatErrorSync(decoded.left)}`);
|
|
54
|
+
}
|
|
55
|
+
return migrated;
|
|
56
|
+
}
|
|
57
|
+
exports.assertionsV1Maintenance = Object.freeze({
|
|
58
|
+
historicalCodecs: Object.freeze([
|
|
59
|
+
Object.freeze({
|
|
60
|
+
schemaVersion: 1,
|
|
61
|
+
decode: decodeAssertionsV1,
|
|
62
|
+
verify: (payload, blobs) => {
|
|
63
|
+
const previous = parseAssertionsV1(payload);
|
|
64
|
+
const byRef = new Map(blobs.map((blob) => [blob.ref, blob.bytes]));
|
|
65
|
+
const materials = previous.entries.flatMap((entry) => [entry.subject, ...entry.evidence]);
|
|
66
|
+
return materials.every((material) => {
|
|
67
|
+
if (material.kind !== "blob")
|
|
68
|
+
return true;
|
|
69
|
+
const bytes = byRef.get(material.ref);
|
|
70
|
+
return bytes !== undefined &&
|
|
71
|
+
bytes.byteLength === material.byteLength &&
|
|
72
|
+
(0, node_crypto_1.createHash)("sha256").update(bytes).digest("hex") === material.sha256;
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
]),
|
|
77
|
+
adjacentMigrations: Object.freeze([
|
|
78
|
+
Object.freeze({
|
|
79
|
+
fromSchemaVersion: 1,
|
|
80
|
+
toSchemaVersion: 2,
|
|
81
|
+
retention: Object.freeze({
|
|
82
|
+
retainedFacts: Object.freeze([
|
|
83
|
+
"display",
|
|
84
|
+
"decision",
|
|
85
|
+
"provable-policy",
|
|
86
|
+
"contribution",
|
|
87
|
+
"source-sites",
|
|
88
|
+
]),
|
|
89
|
+
droppedFacts: Object.freeze([
|
|
90
|
+
"criterion",
|
|
91
|
+
"subject",
|
|
92
|
+
"evidence",
|
|
93
|
+
"coverage",
|
|
94
|
+
"limitations",
|
|
95
|
+
"result.diagnostic",
|
|
96
|
+
"result.receipt",
|
|
97
|
+
]),
|
|
98
|
+
rerunRecommendation: "Rerun the affected evaluation to collect current assertion facts.",
|
|
99
|
+
}),
|
|
100
|
+
migrate: migrateAssertionsV1,
|
|
101
|
+
}),
|
|
102
|
+
]),
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=assertions-v1.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions-v1.js","sourceRoot":"","sources":["assertions-v1.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,mCAAqD;AAErD,8CAA2D;AAE3D,mDAA2F;AAC3F,SAAS,iBAAiB,CAAC,KAAc;IACrC,MAAM,OAAO,GAAG,eAAM,CAAC,mBAAmB,CAAC,4CAA4B,EAAE,iCAAuB,CAAC,CAAC,KAAK,CAAC,CAAC;IACzG,IAAI,eAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACxD,OAAO,OAAO,CAAC,KAAK,CAAC;AACzB,CAAC;AACD,SAAS,kBAAkB,CAAC,KAAc;IACtC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO,KAAK,CAAC;AACjB,CAAC;AACD,yFAAyF;AACzF,SAAS,mBAAmB,CAAC,KAAc;IACvC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;YACxE,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,aAAsB,EAAE,MAAM,EAAE,cAAuB,EAAE,CAAC;YAC5F,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;gBACrB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,aAAsB,E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IAAI,CAAC;oBAChB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;oBACtC,OAAO,KAAK,KAAK,SAAS;wBACtB,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU;wBACxC,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC,MAAM,CAAC;gBAC7E,CAAC,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;KACL,CAAC;IACF,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC;YACV,iBAAiB,EAAE,CAAC;YACpB,eAAe,EAAE,CAAC;YAClB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;gBACrB,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC;oBACzB,SAAS;oBACT,UAAU;oBACV,iBAAiB;oBACjB,cAAc;oBACd,cAAc;iBACjB,CAAC;gBACF,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC;oBACxB,WAAW;oBACX,SAAS;oBACT,UAAU;oBACV,UAAU;oBACV,aAAa;oBACb,mBAAmB;oBACnB,gBAAgB;iBACnB,CAAC;gBACF,mBAAmB,EAAE,mEAAmE;aAC3F,CAAC;YACF,OAAO,EAAE,mBAAmB;SAC/B,CAAC;KACL,CAAC;CACL,CAAC,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { Either, ParseResult, Schema } from \"effect\";\nimport type { RecordBlobRef } from \"../attachment/blob-ref.ts\";\nimport { RecordExactParseOptions } from \"../codec/core.ts\";\nimport type { RecordAttachmentMaintenanceFacet } from \"../definition/attachment.ts\";\nimport { AssertionsAttachmentSchema, AssertionsAttachmentV1Schema } from \"./assertions.ts\";\nfunction parseAssertionsV1(value: unknown): Schema.Schema.Type<typeof AssertionsAttachmentV1Schema> {\n const decoded = Schema.decodeUnknownEither(AssertionsAttachmentV1Schema, RecordExactParseOptions)(value);\n if (Either.isLeft(decoded))\n throw new Error(\"Assertions v1 payload is invalid\");\n return decoded.right;\n}\nfunction decodeAssertionsV1(value: unknown): unknown {\n parseAssertionsV1(value);\n return value;\n}\n/** Pure adjacent payload transform. Record maintenance exclusively owns physical I/O. */\nfunction migrateAssertionsV1(value: unknown): unknown {\n const previous = parseAssertionsV1(value);\n const migrated = Object.freeze({\n \"entries-data\": Object.freeze(previous.entries.map((entry) => Object.freeze({\n entryId: entry.entryId,\n display: entry.display,\n criterion: Object.freeze({ state: \"unavailable\" as const, reason: \"not-recorded\" as const }),\n materials: Object.freeze({\n source: Object.freeze({ kind: \"unavailable\" as const, reason: \"not-recorded\" as const }),\n evidence: Object.freeze([]),\n coverage: Object.freeze({ state: \"unavailable\" as const, reason: \"not-collected\" as const }),\n limitations: Object.freeze([]),\n }),\n evaluation: Object.freeze({\n observed: Object.freeze({ kind: \"unavailable\" as const, reason: \"not-recorded\" as const }),\n }),\n decision: Object.freeze({\n result: entry.result.state,\n reason: \"reason\" in entry.result ? entry.result.reason : null,\n gate: entry.result.gate,\n }),\n policy: Object.freeze({\n requirement: entry.result.gate === \"not-gate\"\n ? Object.freeze({ state: \"unavailable\" as const, reason: \"not-recorded\" as const })\n : Object.freeze({ state: \"available\" as const, value: \"required\" as const }),\n condition: Object.freeze({ state: \"unavailable\" as const, reason: \"not-recorded\" as const }),\n }),\n contribution: entry.result.score,\n explanationRetention: Object.freeze({ state: \"unavailable\" as const, reason: \"not-recorded\" as const }),\n }))),\n \"source-sites-data\": previous.sourceSites,\n });\n const decoded = Schema.decodeUnknownEither(AssertionsAttachmentSchema, RecordExactParseOptions)(migrated);\n if (Either.isLeft(decoded)) {\n throw new Error(`Assertions v1 migration did not produce a current payload: ${ParseResult.TreeFormatter.formatErrorSync(decoded.left)}`);\n }\n return migrated;\n}\nexport const assertionsV1Maintenance: RecordAttachmentMaintenanceFacet = Object.freeze({\n historicalCodecs: Object.freeze([\n Object.freeze({\n schemaVersion: 1,\n decode: decodeAssertionsV1,\n verify: (payload: unknown, blobs: readonly {\n readonly ref: RecordBlobRef;\n readonly bytes: Uint8Array;\n }[]) => {\n const previous = parseAssertionsV1(payload);\n const byRef = new Map(blobs.map((blob) => [blob.ref, blob.bytes] as const));\n const materials = previous.entries.flatMap((entry) => [entry.subject, ...entry.evidence]);\n return materials.every((material) => {\n if (material.kind !== \"blob\")\n return true;\n const bytes = byRef.get(material.ref);\n return bytes !== undefined &&\n bytes.byteLength === material.byteLength &&\n createHash(\"sha256\").update(bytes).digest(\"hex\") === material.sha256;\n });\n },\n }),\n ]),\n adjacentMigrations: Object.freeze([\n Object.freeze({\n fromSchemaVersion: 1,\n toSchemaVersion: 2,\n retention: Object.freeze({\n retainedFacts: Object.freeze([\n \"display\",\n \"decision\",\n \"provable-policy\",\n \"contribution\",\n \"source-sites\",\n ]),\n droppedFacts: Object.freeze([\n \"criterion\",\n \"subject\",\n \"evidence\",\n \"coverage\",\n \"limitations\",\n \"result.diagnostic\",\n \"result.receipt\",\n ]),\n rerunRecommendation: \"Rerun the affected evaluation to collect current assertion facts.\",\n }),\n migrate: migrateAssertionsV1,\n }),\n ]),\n});\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire as __niceevalCreateRequire } from "node:module";
|
|
2
|
+
const __niceevalRequire = __niceevalCreateRequire(import.meta.url);
|
|
3
|
+
const __niceevalCanonical = __niceevalRequire("./assertions-v1.cjs");
|
|
4
|
+
const __niceevalExport0 = __niceevalCanonical["assertionsV1Maintenance"];
|
|
5
|
+
export { __niceevalExport0 as assertionsV1Maintenance };
|
|
6
|
+
//# sourceMappingURL=assertions-v1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions-v1.js","sources":[],"names":[],"mappings":""}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const __niceevalDynamicImport = (specifier) => import(specifier);
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertionsRecordAttachment = exports.AssertionsAttachmentSchema = exports.AssertionSourceSitesSchema = exports.AssertionsEntriesSchema = exports.AssertionSourceSiteSchema = void 0;
|
|
4
|
+
exports.assertionsRecordAttachment = exports.AssertionsAttachmentV1Schema = exports.AssertionsAttachmentSchema = exports.AssertionSourceSitesSchema = exports.AssertionsEntriesV1Schema = exports.AssertionsEntriesSchema = exports.AssertionSourceSiteSchema = void 0;
|
|
4
5
|
exports.assertionsBlobRefs = assertionsBlobRefs;
|
|
5
6
|
exports.assertionsAttachmentIntegrityIssues = assertionsAttachmentIntegrityIssues;
|
|
6
7
|
exports.assertionsSourceSiteIntegrityIssues = assertionsSourceSiteIntegrityIssues;
|
|
@@ -34,10 +35,11 @@ exports.AssertionSourceSiteSchema = effect_1.Schema.Struct({
|
|
|
34
35
|
const assertionSchemas = (0, codec_ts_1.createAssertionsRecordSchemas)(blob_ref_ts_1.RecordBlobRefSchema);
|
|
35
36
|
/** Reuse the existing v1 entry schema inside the one direct attachment schema. */
|
|
36
37
|
exports.AssertionsEntriesSchema = assertionSchemas.entries;
|
|
38
|
+
exports.AssertionsEntriesV1Schema = assertionSchemas.historicalEntries;
|
|
37
39
|
exports.AssertionSourceSitesSchema = effect_1.Schema.Array(exports.AssertionSourceSiteSchema);
|
|
38
40
|
function hasNoLegacyAttachmentMaterial(document) {
|
|
39
41
|
const materialIsAllowed = (material) => material.kind !== "record-attachment";
|
|
40
|
-
return document.entries.every((entry) => materialIsAllowed(entry.
|
|
42
|
+
return document.entries.every((entry) => materialIsAllowed(entry.materials.source) && entry.materials.evidence.every(materialIsAllowed));
|
|
41
43
|
}
|
|
42
44
|
function hasCanonicalSourceSites(payload) {
|
|
43
45
|
const entryIds = new Set(payload.entries.map((entry) => entry.entryId));
|
|
@@ -94,6 +96,11 @@ exports.AssertionsAttachmentSchema = effect_1.Schema.Struct({
|
|
|
94
96
|
identifier: "AssertionsSourceSites",
|
|
95
97
|
description: "source sites join local entries with unique canonical source order",
|
|
96
98
|
}));
|
|
99
|
+
/** @internal Package-private historical wire codec, loaded only by maintenance. */
|
|
100
|
+
exports.AssertionsAttachmentV1Schema = effect_1.Schema.Struct({
|
|
101
|
+
entries: effect_1.Schema.propertySignature(exports.AssertionsEntriesV1Schema).pipe(effect_1.Schema.fromKey("entries-data")),
|
|
102
|
+
sourceSites: effect_1.Schema.propertySignature(exports.AssertionSourceSitesSchema).pipe(effect_1.Schema.fromKey("source-sites-data")),
|
|
103
|
+
});
|
|
97
104
|
/** Complete closure projection for `niceeval.assertions`. */
|
|
98
105
|
function assertionsBlobRefs(payload) {
|
|
99
106
|
return (0, attachment_ts_1.assertionBlobRefs)(payload);
|
|
@@ -121,8 +128,8 @@ function assertionsAttachmentIntegrityIssues(payload, blobs) {
|
|
|
121
128
|
}
|
|
122
129
|
};
|
|
123
130
|
for (const [index, entry] of payload.entries.entries()) {
|
|
124
|
-
validateMaterial(entry.
|
|
125
|
-
for (const [evidenceIndex, material] of entry.evidence.entries()) {
|
|
131
|
+
validateMaterial(entry.materials.source, ["entries", String(index), "materials", "source"]);
|
|
132
|
+
for (const [evidenceIndex, material] of entry.materials.evidence.entries()) {
|
|
126
133
|
validateMaterial(material, ["entries", String(index), "evidence", String(evidenceIndex)]);
|
|
127
134
|
}
|
|
128
135
|
}
|
|
@@ -155,7 +162,7 @@ const AssertionsBlobBudget = Object.freeze({
|
|
|
155
162
|
exports.assertionsRecordAttachment = (0, index_ts_1.defineRecordAttachment)({
|
|
156
163
|
family: "niceeval.assertions",
|
|
157
164
|
current: {
|
|
158
|
-
schemaVersion:
|
|
165
|
+
schemaVersion: 2,
|
|
159
166
|
owners: {
|
|
160
167
|
attempt: {
|
|
161
168
|
schema: exports.AssertionsAttachmentSchema,
|
|
@@ -168,5 +175,9 @@ exports.assertionsRecordAttachment = (0, index_ts_1.defineRecordAttachment)({
|
|
|
168
175
|
},
|
|
169
176
|
},
|
|
170
177
|
},
|
|
178
|
+
maintenance: () => __niceevalDynamicImport("./assertions-v1.cjs").then(({ assertionsV1Maintenance }) => assertionsV1Maintenance),
|
|
179
|
+
adjacentMigrationLinks: Object.freeze([
|
|
180
|
+
Object.freeze({ fromSchemaVersion: 1, toSchemaVersion: 2, rewritePayload: true }),
|
|
181
|
+
]),
|
|
171
182
|
});
|
|
172
183
|
//# sourceMappingURL=assertions.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["assertions.ts"],"names":[],"mappings":";;;AAkHA,gDAEC;AAED,kFA+BC;AAMD,kFAYC;AAvKD,6CAAyC;AACzC,mCAAgC;AAChC,yEAA0E;AAC1E,+DAAwI;AACxI,2DAAqF;AACrF,uDAA4F;AAC5F,qDAAgE;AAChE,4DAAkF;AAClF,2CAAqF;AAErF,MAAM,yBAAyB,GAAG,eAAM,CAAC,OAAO,CAAC,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AAClH,MAAM,6BAA6B,GAAG,eAAM,CAAC,MAAM,CAAC;IAChD,IAAI,EAAE,qCAAyB;IAC/B,MAAM,EAAE,qCAAyB;CACpC,CAAC,CAAC;AACH;;;GAGG;AACU,QAAA,yBAAyB,GAAG,eAAM,CAAC,MAAM,CAAC;IACnD,OAAO,EAAE,iCAAsB;IAC/B,WAAW,EAAE,qCAAyB;IACtC,IAAI,EAAE,yBAAyB;IAC/B,YAAY,EAAE,mCAAkB;IAChC,MAAM,EAAE,mCAAkB;IAC1B,KAAK,EAAE,6BAA6B;IACpC,GAAG,EAAE,6BAA6B;CACrC,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,IAAA,wCAA6B,EAAC,iCAAmB,CAAC,CAAC;AAC5E,kFAAkF;AACrE,QAAA,uBAAuB,GAAG,gBAAgB,CAAC,OAAO,CAAC;AACnD,QAAA,0BAA0B,GAAG,eAAM,CAAC,KAAK,C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AAK,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/E,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,IAAI,cAAc,EAAE,CAAC;YAC1E,MAAM,CAAC,IAAI,CAAC,IAAA,iCAAqB,EAAC,wCAAwC,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACjH,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AACD,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,YAAY,EAAE,KAAK;IACnB,gBAAgB,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAClC,iBAAiB,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;CACtC,CAAC,CAAC;AACH,4EAA4E;AAC/D,QAAA,0BAA0B,GAAG,IAAA,iCAAsB,EAAC;IAC7D,MAAM,EAAE,qBAAqB;IAC7B,OAAO,EAAE;QACL,aAAa,EAAE,CAAC;QAChB,MAAM,EAAE;YACJ,OAAO,EAAE;gBACL,MAAM,EAAE,kCAA0B;gBAClC,MAAM,EAAE,sCAA0B;gBAClC,KAAK,EAAE;oBACH,IAAI,EAAE,kBAAkB;oBACxB,MAAM,EAAE,oBAAoB;oBAC5B,MAAM,EAAE,mCAAmC;iBAC9C;aACJ;SACJ;KACJ;CACJ,CAAC,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { Schema } from \"effect\";\nimport { assertionBlobRefs } from \"../../assertions/record/attachment.ts\";\nimport { AssertionEntryIdSchema, MAX_ASSERTION_DOCUMENT_BYTES, createAssertionsRecordSchemas, } from \"../../assertions/record/codec.ts\";\nimport { RecordBlobRefSchema, type RecordBlobRef, } from \"../attachment/blob-ref.ts\";\nimport { recordAttachmentIssue, type RecordAttachmentIssue } from \"../attachment/errors.ts\";\nimport { defineRecordAttachment } from \"../definition/index.ts\";\nimport { Sha256DigestSchema, SourceItemIdSchema, } from \"../codec/identifiers.ts\";\nimport { FixedAttachmentValueLimits, PositiveSafeIntegerSchema, } from \"./common.ts\";\nimport type { SourcesAttachment } from \"./sources.ts\";\nconst AssertionSourceRoleSchema = Schema.Literal(\"declaration\", \"threshold\", \"score\", \"gate\", \"optional\", \"stop\");\nconst AssertionSourcePositionSchema = Schema.Struct({\n line: PositiveSafeIntegerSchema,\n column: PositiveSafeIntegerSchema,\n});\n/**\n * A source site is a semantic join only. It names an item in the exact origin\n * Run Sources payload and never gains that payload's blob capability.\n */\nexport const AssertionSourceSiteSchema = Schema.Struct({\n entryId: AssertionEntryIdSchema,\n sourceOrder: PositiveSafeIntegerSchema,\n role: AssertionSourceRoleSchema,\n sourceItemId: SourceItemIdSchema,\n sha256: Sha256DigestSchema,\n start: AssertionSourcePositionSchema,\n end: AssertionSourcePositionSchema,\n});\nexport type AssertionSourceSite = Schema.Schema.Type<typeof AssertionSourceSiteSchema>;\nconst assertionSchemas = createAssertionsRecordSchemas(RecordBlobRefSchema);\n/** Reuse the existing v1 entry schema inside the one direct attachment schema. */\nexport const AssertionsEntriesSchema = assertionSchemas.entries;\nexport const AssertionSourceSitesSchema = Schema.Array(AssertionSourceSiteSchema);\nfunction hasNoLegacyAttachmentMaterial(document: {\n readonly entries: readonly {\n readonly subject: {\n readonly kind: string;\n };\n readonly evidence: readonly {\n readonly kind: string;\n }[];\n }[];\n}): boolean {\n const materialIsAllowed = (material: {\n readonly kind: string;\n }): boolean => material.kind !== \"record-attachment\";\n return document.entries.every((entry) => materialIsAllowed(entry.subject) && entry.evidence.every(materialIsAllowed));\n}\nfunction hasCanonicalSourceSites(payload: {\n readonly entries: readonly {\n readonly entryId: string;\n }[];\n readonly sourceSites: readonly AssertionSourceSite[];\n}): boolean {\n const entryIds = new Set(payload.entries.map((entry) => entry.entryId));\n const seenOrders = new Set<number>();\n let previous: string | undefined;\n for (const site of payload.sourceSites) {\n if (!entryIds.has(site.entryId) || seenOrders.has(site.sourceOrder))\n return false;\n seenOrders.add(site.sourceOrder);\n const key = `${site.entryId}\\u0000${site.sourceOrder.toString().padStart(16, \"0\")}`;\n if (previous !== undefined && previous >= key)\n return false;\n previous = key;\n }\n return true;\n}\nfunction hasUniqueAssertionEntryIds(document: {\n readonly entries: readonly {\n readonly entryId: string;\n }[];\n}): boolean {\n const entryIds = new Set<string>();\n for (const entry of document.entries) {\n if (entryIds.has(entry.entryId))\n return false;\n entryIds.add(entry.entryId);\n }\n return true;\n}\nfunction isAssertionsDocumentWithinSizeLimit(value: unknown): boolean {\n try {\n const serialized = JSON.stringify(value);\n return typeof serialized === \"string\" &&\n new TextEncoder().encode(serialized).byteLength <= MAX_ASSERTION_DOCUMENT_BYTES;\n }\n catch {\n return false;\n }\n}\n/**\n * `sourceSites` is embedded in the fixed Assertions payload. The former\n * `niceeval.assertion-source-sites/v1` family is not part of Record v1.\n */\n/** One direct current schema: Type fields and durable keys share all v1 filters. */\nexport const AssertionsAttachmentSchema = Schema.Struct({\n entries: Schema.propertySignature(AssertionsEntriesSchema).pipe(Schema.fromKey(\"entries-data\")),\n sourceSites: Schema.propertySignature(AssertionSourceSitesSchema).pipe(Schema.fromKey(\"source-sites-data\")),\n}).pipe(Schema.filter(hasUniqueAssertionEntryIds, {\n identifier: \"AssertionsUniqueEntryIds\",\n description: \"unique attachment-local assertion entry IDs\",\n}), Schema.filter(isAssertionsDocumentWithinSizeLimit, {\n identifier: \"AssertionsDocumentSize\",\n description: \"a JSON document no larger than 4 MiB\",\n}), Schema.filter(hasNoLegacyAttachmentMaterial, {\n identifier: \"AssertionsNoLegacyAttachmentMaterial\",\n description: \"Assertions do not reference retired attachment families\",\n}), Schema.filter(hasCanonicalSourceSites, {\n identifier: \"AssertionsSourceSites\",\n description: \"source sites join local entries with unique canonical source order\",\n}));\nexport type AssertionsAttachment = Schema.Schema.Type<typeof AssertionsAttachmentSchema>;\n/** Complete closure projection for `niceeval.assertions`. */\nexport function assertionsBlobRefs(payload: AssertionsAttachment): readonly RecordBlobRef[] {\n return assertionBlobRefs(payload);\n}\n/** Binds every Assertions blob declaration to its exact materialized bytes. */\nexport function assertionsAttachmentIntegrityIssues(payload: AssertionsAttachment, blobs: readonly {\n readonly ref: RecordBlobRef;\n readonly bytes: Uint8Array;\n}[]): readonly RecordAttachmentIssue[] {\n const bytesByRef = new Map<RecordBlobRef, Uint8Array>(blobs.map((blob) => [blob.ref, blob.bytes] as const));\n const issues: RecordAttachmentIssue[] = [];\n const validateMaterial = (material: AssertionsAttachment[\"entries\"][number][\"subject\"], path: readonly string[]) => {\n if (material.kind !== \"blob\")\n return;\n const bytes = bytesByRef.get(material.ref);\n if (bytes === undefined || bytes.byteLength !== material.byteLength) {\n issues.push(recordAttachmentIssue(\"record-attachment-materialized-invalid\", [\n ...path,\n bytes === undefined ? \"ref\" : \"byteLength\",\n ]));\n return;\n }\n if (createHash(\"sha256\").update(bytes).digest(\"hex\") !== material.sha256) {\n issues.push(recordAttachmentIssue(\"record-attachment-materialized-invalid\", [\n ...path,\n \"sha256\",\n ]));\n }\n };\n for (const [index, entry] of payload.entries.entries()) {\n validateMaterial(entry.subject, [\"entries\", String(index), \"subject\"]);\n for (const [evidenceIndex, material] of entry.evidence.entries()) {\n validateMaterial(material, [\"entries\", String(index), \"evidence\", String(evidenceIndex)]);\n }\n }\n return Object.freeze(issues);\n}\n/**\n * Host-only semantic join to the exact origin Sources manifest. The row owns\n * neither source bytes nor a blob capability, so this check deliberately\n * compares only the explicit item identity, digest, and stored coordinates.\n */\nexport function assertionsSourceSiteIntegrityIssues(payload: AssertionsAttachment, sources: SourcesAttachment): readonly RecordAttachmentIssue[] {\n const sourceById = new Map(sources.items.map((item) => [item.sourceItemId, item] as const));\n const issues: RecordAttachmentIssue[] = [];\n for (const [index, site] of payload.sourceSites.entries()) {\n const source = sourceById.get(site.sourceItemId);\n const startsAfterEnd = site.start.line > site.end.line ||\n (site.start.line === site.end.line && site.start.column > site.end.column);\n if (source === undefined || source.sha256 !== site.sha256 || startsAfterEnd) {\n issues.push(recordAttachmentIssue(\"record-attachment-materialized-invalid\", [\"sourceSites\", String(index)]));\n }\n }\n return Object.freeze(issues);\n}\nconst AssertionsBlobBudget = Object.freeze({\n maximumBlobs: 20000,\n maximumBlobBytes: 16 * 1024 * 1024,\n maximumTotalBytes: 64 * 1024 * 1024,\n});\n/** The sole current declaration for the Attempt-owned Assertions family. */\nexport const assertionsRecordAttachment = defineRecordAttachment({\n family: \"niceeval.assertions\",\n current: {\n schemaVersion: 1,\n owners: {\n attempt: {\n schema: AssertionsAttachmentSchema,\n limits: FixedAttachmentValueLimits,\n blobs: {\n refs: assertionsBlobRefs,\n budget: AssertionsBlobBudget,\n verify: assertionsAttachmentIntegrityIssues,\n },\n },\n },\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["assertions.ts"],"names":[],"mappings":";;;AA0HA,gDAEC;AAED,kFA+BC;AAMD,kFAYC;AA/KD,6CAAyC;AACzC,mCAAgC;AAChC,yEAA0E;AAC1E,+DAAwI;AACxI,2DAAqF;AACrF,uDAA4F;AAC5F,qDAAgE;AAChE,4DAAkF;AAClF,2CAAqF;AAErF,MAAM,yBAAyB,GAAG,eAAM,CAAC,OAAO,CAAC,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AAClH,MAAM,6BAA6B,GAAG,eAAM,CAAC,MAAM,CAAC;IAChD,IAAI,EAAE,qCAAyB;IAC/B,MAAM,EAAE,qCAAyB;CACpC,CAAC,CAAC;AACH;;;GAGG;AACU,QAAA,yBAAyB,GAAG,eAAM,CAAC,MAAM,CAAC;IACnD,OAAO,EAAE,iCAAsB;IAC/B,WAAW,EAAE,qCAAyB;IACtC,IAAI,EAAE,yBAAyB;IAC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,CAAC;IACvC,YAAY,EAAE,KAAK;IACnB,gBAAgB,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAClC,iBAAiB,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;CACtC,CAAC,CAAC;AACH,4EAA4E;AAC/D,QAAA,0BAA0B,GAAG,IAAA,iCAAsB,EAAC;IAC7D,MAAM,EAAE,qBAAqB;IAC7B,OAAO,EAAE;QACL,aAAa,EAAE,CAAC;QAChB,MAAM,EAAE;YACJ,OAAO,EAAE;gBACL,MAAM,EAAE,kCAA0B;gBAClC,MAAM,EAAE,sCAA0B;gBAClC,KAAK,EAAE;oBACH,IAAI,EAAE,kBAAkB;oBACxB,MAAM,EAAE,oBAAoB;oBAC5B,MAAM,EAAE,mCAAmC;iBAC9C;aACJ;SACJ;KACJ;IACD,WAAW,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,uBAAuB,EAAE,EAAE,EAAE,CAAC,uBAAuB,CAAC;IAChI,sBAAsB,EAAE,MAAM,CAAC,MAAM,CAAC;QAClC,MAAM,CAAC,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;KACpF,CAAC;CACL,CAAC,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { Schema } from \"effect\";\nimport { assertionBlobRefs } from \"../../assertions/record/attachment.ts\";\nimport { AssertionEntryIdSchema, MAX_ASSERTION_DOCUMENT_BYTES, createAssertionsRecordSchemas, } from \"../../assertions/record/codec.ts\";\nimport { RecordBlobRefSchema, type RecordBlobRef, } from \"../attachment/blob-ref.ts\";\nimport { recordAttachmentIssue, type RecordAttachmentIssue } from \"../attachment/errors.ts\";\nimport { defineRecordAttachment } from \"../definition/index.ts\";\nimport { Sha256DigestSchema, SourceItemIdSchema, } from \"../codec/identifiers.ts\";\nimport { FixedAttachmentValueLimits, PositiveSafeIntegerSchema, } from \"./common.ts\";\nimport type { SourcesAttachment } from \"./sources.ts\";\nconst AssertionSourceRoleSchema = Schema.Literal(\"declaration\", \"threshold\", \"score\", \"gate\", \"optional\", \"stop\");\nconst AssertionSourcePositionSchema = Schema.Struct({\n line: PositiveSafeIntegerSchema,\n column: PositiveSafeIntegerSchema,\n});\n/**\n * A source site is a semantic join only. It names an item in the exact origin\n * Run Sources payload and never gains that payload's blob capability.\n */\nexport const AssertionSourceSiteSchema = Schema.Struct({\n entryId: AssertionEntryIdSchema,\n sourceOrder: PositiveSafeIntegerSchema,\n role: AssertionSourceRoleSchema,\n sourceItemId: SourceItemIdSchema,\n sha256: Sha256DigestSchema,\n start: AssertionSourcePositionSchema,\n end: AssertionSourcePositionSchema,\n});\nexport type AssertionSourceSite = Schema.Schema.Type<typeof AssertionSourceSiteSchema>;\nconst assertionSchemas = createAssertionsRecordSchemas(RecordBlobRefSchema);\n/** Reuse the existing v1 entry schema inside the one direct attachment schema. */\nexport const AssertionsEntriesSchema = assertionSchemas.entries;\nexport const AssertionsEntriesV1Schema = assertionSchemas.historicalEntries;\nexport const AssertionSourceSitesSchema = Schema.Array(AssertionSourceSiteSchema);\nfunction hasNoLegacyAttachmentMaterial(document: {\n readonly entries: readonly {\n readonly materials: {\n readonly source: {\n readonly kind: string;\n };\n readonly evidence: readonly {\n readonly kind: string;\n }[];\n };\n }[];\n}): boolean {\n const materialIsAllowed = (material: {\n readonly kind: string;\n }): boolean => material.kind !== \"record-attachment\";\n return document.entries.every((entry) => materialIsAllowed(entry.materials.source) && entry.materials.evidence.every(materialIsAllowed));\n}\nfunction hasCanonicalSourceSites(payload: {\n readonly entries: readonly {\n readonly entryId: string;\n }[];\n readonly sourceSites: readonly AssertionSourceSite[];\n}): boolean {\n const entryIds = new Set(payload.entries.map((entry) => entry.entryId));\n const seenOrders = new Set<number>();\n let previous: string | undefined;\n for (const site of payload.sourceSites) {\n if (!entryIds.has(site.entryId) || seenOrders.has(site.sourceOrder))\n return false;\n seenOrders.add(site.sourceOrder);\n const key = `${site.entryId}\\u0000${site.sourceOrder.toString().padStart(16, \"0\")}`;\n if (previous !== undefined && previous >= key)\n return false;\n previous = key;\n }\n return true;\n}\nfunction hasUniqueAssertionEntryIds(document: {\n readonly entries: readonly {\n readonly entryId: string;\n }[];\n}): boolean {\n const entryIds = new Set<string>();\n for (const entry of document.entries) {\n if (entryIds.has(entry.entryId))\n return false;\n entryIds.add(entry.entryId);\n }\n return true;\n}\nfunction isAssertionsDocumentWithinSizeLimit(value: unknown): boolean {\n try {\n const serialized = JSON.stringify(value);\n return typeof serialized === \"string\" &&\n new TextEncoder().encode(serialized).byteLength <= MAX_ASSERTION_DOCUMENT_BYTES;\n }\n catch {\n return false;\n }\n}\n/**\n * `sourceSites` is embedded in the fixed Assertions payload. The former\n * `niceeval.assertion-source-sites/v1` family is not part of Record v1.\n */\n/** One direct current schema: Type fields and durable keys share all v1 filters. */\nexport const AssertionsAttachmentSchema = Schema.Struct({\n entries: Schema.propertySignature(AssertionsEntriesSchema).pipe(Schema.fromKey(\"entries-data\")),\n sourceSites: Schema.propertySignature(AssertionSourceSitesSchema).pipe(Schema.fromKey(\"source-sites-data\")),\n}).pipe(Schema.filter(hasUniqueAssertionEntryIds, {\n identifier: \"AssertionsUniqueEntryIds\",\n description: \"unique attachment-local assertion entry IDs\",\n}), Schema.filter(isAssertionsDocumentWithinSizeLimit, {\n identifier: \"AssertionsDocumentSize\",\n description: \"a JSON document no larger than 4 MiB\",\n}), Schema.filter(hasNoLegacyAttachmentMaterial, {\n identifier: \"AssertionsNoLegacyAttachmentMaterial\",\n description: \"Assertions do not reference retired attachment families\",\n}), Schema.filter(hasCanonicalSourceSites, {\n identifier: \"AssertionsSourceSites\",\n description: \"source sites join local entries with unique canonical source order\",\n}));\n/** @internal Package-private historical wire codec, loaded only by maintenance. */\nexport const AssertionsAttachmentV1Schema = Schema.Struct({\n entries: Schema.propertySignature(AssertionsEntriesV1Schema).pipe(Schema.fromKey(\"entries-data\")),\n sourceSites: Schema.propertySignature(AssertionSourceSitesSchema).pipe(Schema.fromKey(\"source-sites-data\")),\n});\nexport type AssertionsAttachment = Schema.Schema.Type<typeof AssertionsAttachmentSchema>;\n/** Complete closure projection for `niceeval.assertions`. */\nexport function assertionsBlobRefs(payload: AssertionsAttachment): readonly RecordBlobRef[] {\n return assertionBlobRefs(payload);\n}\n/** Binds every Assertions blob declaration to its exact materialized bytes. */\nexport function assertionsAttachmentIntegrityIssues(payload: AssertionsAttachment, blobs: readonly {\n readonly ref: RecordBlobRef;\n readonly bytes: Uint8Array;\n}[]): readonly RecordAttachmentIssue[] {\n const bytesByRef = new Map<RecordBlobRef, Uint8Array>(blobs.map((blob) => [blob.ref, blob.bytes] as const));\n const issues: RecordAttachmentIssue[] = [];\n const validateMaterial = (material: AssertionsAttachment[\"entries\"][number][\"materials\"][\"source\"], path: readonly string[]) => {\n if (material.kind !== \"blob\")\n return;\n const bytes = bytesByRef.get(material.ref);\n if (bytes === undefined || bytes.byteLength !== material.byteLength) {\n issues.push(recordAttachmentIssue(\"record-attachment-materialized-invalid\", [\n ...path,\n bytes === undefined ? \"ref\" : \"byteLength\",\n ]));\n return;\n }\n if (createHash(\"sha256\").update(bytes).digest(\"hex\") !== material.sha256) {\n issues.push(recordAttachmentIssue(\"record-attachment-materialized-invalid\", [\n ...path,\n \"sha256\",\n ]));\n }\n };\n for (const [index, entry] of payload.entries.entries()) {\n validateMaterial(entry.materials.source, [\"entries\", String(index), \"materials\", \"source\"]);\n for (const [evidenceIndex, material] of entry.materials.evidence.entries()) {\n validateMaterial(material, [\"entries\", String(index), \"evidence\", String(evidenceIndex)]);\n }\n }\n return Object.freeze(issues);\n}\n/**\n * Host-only semantic join to the exact origin Sources manifest. The row owns\n * neither source bytes nor a blob capability, so this check deliberately\n * compares only the explicit item identity, digest, and stored coordinates.\n */\nexport function assertionsSourceSiteIntegrityIssues(payload: AssertionsAttachment, sources: SourcesAttachment): readonly RecordAttachmentIssue[] {\n const sourceById = new Map(sources.items.map((item) => [item.sourceItemId, item] as const));\n const issues: RecordAttachmentIssue[] = [];\n for (const [index, site] of payload.sourceSites.entries()) {\n const source = sourceById.get(site.sourceItemId);\n const startsAfterEnd = site.start.line > site.end.line ||\n (site.start.line === site.end.line && site.start.column > site.end.column);\n if (source === undefined || source.sha256 !== site.sha256 || startsAfterEnd) {\n issues.push(recordAttachmentIssue(\"record-attachment-materialized-invalid\", [\"sourceSites\", String(index)]));\n }\n }\n return Object.freeze(issues);\n}\nconst AssertionsBlobBudget = Object.freeze({\n maximumBlobs: 20000,\n maximumBlobBytes: 16 * 1024 * 1024,\n maximumTotalBytes: 64 * 1024 * 1024,\n});\n/** The sole current declaration for the Attempt-owned Assertions family. */\nexport const assertionsRecordAttachment = defineRecordAttachment({\n family: \"niceeval.assertions\",\n current: {\n schemaVersion: 2,\n owners: {\n attempt: {\n schema: AssertionsAttachmentSchema,\n limits: FixedAttachmentValueLimits,\n blobs: {\n refs: assertionsBlobRefs,\n budget: AssertionsBlobBudget,\n verify: assertionsAttachmentIntegrityIssues,\n },\n },\n },\n },\n maintenance: () => __niceevalDynamicImport(\"./assertions-v1.cjs\").then(({ assertionsV1Maintenance }) => assertionsV1Maintenance),\n adjacentMigrationLinks: Object.freeze([\n Object.freeze({ fromSchemaVersion: 1, toSchemaVersion: 2, rewritePayload: true }),\n ]),\n});\n"]}
|