niceeval 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INDEX.md +23 -23
- package/README.zh.md +6 -6
- package/dist/agents/types.d.ts +69 -7
- package/dist/context/types.d.ts +32 -12
- package/dist/i18n/en.d.ts +54 -0
- package/dist/i18n/zh-CN.d.ts +57 -3
- package/dist/o11y/types.d.ts +16 -2
- package/dist/report/aggregate.d.ts +32 -24
- package/dist/report/aggregate.js +158 -50
- package/dist/report/built-in/index.d.ts +2 -0
- package/dist/report/built-in/index.js +8 -0
- package/dist/report/components.d.ts +93 -160
- package/dist/report/components.js +377 -114
- package/dist/report/compute.d.ts +87 -81
- package/dist/report/compute.js +597 -417
- package/dist/report/flag.d.ts +32 -6
- package/dist/report/flag.js +92 -4
- package/dist/report/format.d.ts +19 -11
- package/dist/report/format.js +30 -13
- package/dist/report/index.d.ts +16 -16
- package/dist/report/index.js +20 -21
- package/dist/report/load.js +3 -2
- package/dist/report/locale.d.ts +57 -33
- package/dist/report/locale.js +122 -56
- package/dist/report/metrics.d.ts +23 -4
- package/dist/report/metrics.js +110 -25
- package/dist/report/primitives.d.ts +48 -15
- package/dist/report/primitives.js +135 -26
- package/dist/report/react/AttemptList.d.ts +9 -7
- package/dist/report/react/AttemptList.js +17 -10
- package/dist/report/react/DeltaTable.js +19 -18
- package/dist/report/react/EvalList.d.ts +4 -4
- package/dist/report/react/EvalList.js +0 -0
- package/dist/report/react/ExperimentComparison.d.ts +10 -0
- package/dist/report/react/ExperimentComparison.js +12 -0
- package/dist/report/react/ExperimentList.d.ts +4 -3
- package/dist/report/react/ExperimentList.js +17 -18
- package/dist/report/react/MetricBars.js +5 -4
- package/dist/report/react/MetricLine.js +12 -5
- package/dist/report/react/MetricMatrix.js +1 -1
- package/dist/report/react/MetricScatter.js +59 -28
- package/dist/report/react/MetricTable.js +2 -12
- package/dist/report/react/ScopeSummary.d.ts +10 -0
- package/dist/report/react/ScopeSummary.js +17 -0
- package/dist/report/react/Scoreboard.js +6 -6
- package/dist/report/react/cell.js +2 -2
- package/dist/report/react/chart-math.d.ts +23 -6
- package/dist/report/react/chart-math.js +71 -19
- package/dist/report/react/fixtures.d.ts +5 -9
- package/dist/report/react/fixtures.js +110 -147
- package/dist/report/react/index.d.ts +15 -5
- package/dist/report/react/index.js +18 -7
- package/dist/report/report.d.ts +137 -16
- package/dist/report/report.js +259 -28
- package/dist/report/text/faces.d.ts +17 -19
- package/dist/report/text/faces.js +253 -184
- package/dist/report/text/plot.js +1 -1
- package/dist/report/text/table.js +38 -7
- package/dist/report/tree.d.ts +90 -40
- package/dist/report/tree.js +252 -94
- package/dist/report/types.d.ts +247 -284
- package/dist/report/types.js +4 -3
- package/dist/report/web.d.ts +21 -5
- package/dist/report/web.js +42 -16
- package/dist/results/select.d.ts +38 -16
- package/dist/results/select.js +73 -25
- package/dist/results/types.d.ts +49 -14
- package/dist/runner/feedback/sink.d.ts +110 -0
- package/dist/runner/types.d.ts +513 -22
- package/dist/sandbox/docker.d.ts +23 -2
- package/dist/sandbox/e2b.d.ts +15 -1
- package/dist/sandbox/errors.d.ts +30 -3
- package/dist/sandbox/io-retry.d.ts +17 -0
- package/dist/sandbox/registry.d.ts +2 -0
- package/dist/sandbox/resolve.d.ts +18 -5
- package/dist/sandbox/retry.d.ts +11 -1
- package/dist/sandbox/types.d.ts +39 -5
- package/dist/sandbox/vercel.d.ts +7 -1
- package/dist/scoring/coverage.d.ts +30 -0
- package/dist/scoring/display.d.ts +21 -0
- package/dist/scoring/display.js +120 -0
- package/dist/scoring/types.d.ts +103 -20
- package/dist/shared/aggregate.d.ts +4 -2
- package/dist/shared/aggregate.js +8 -7
- package/dist/shared/types.d.ts +28 -0
- package/dist/tty-line.d.ts +0 -4
- package/dist/util.d.ts +23 -0
- package/docs-site/zh/README.md +44 -0
- package/docs-site/zh/examples/ai-agent-application.mdx +63 -0
- package/docs-site/zh/examples/coding-agent-extensions.mdx +57 -0
- package/docs-site/zh/examples/index.mdx +50 -0
- package/docs-site/zh/{concepts → explanation}/adapter.mdx +31 -13
- package/docs-site/zh/{concepts → explanation}/assert.mdx +7 -7
- package/docs-site/zh/{concepts → explanation}/drive.mdx +8 -8
- package/docs-site/zh/{concepts → explanation}/evals.mdx +4 -4
- package/docs-site/zh/{concepts → explanation}/experiment.mdx +8 -8
- package/docs-site/zh/{concepts → explanation}/hitl.mdx +8 -8
- package/docs-site/zh/{concepts → explanation}/judge.mdx +5 -5
- package/docs-site/zh/{concepts → explanation}/overview.mdx +11 -11
- package/docs-site/zh/{guides → explanation}/runner.mdx +18 -8
- package/docs-site/zh/{concepts → explanation}/tier.mdx +6 -6
- package/docs-site/zh/{guides → how-to}/agent-feedback-loop.mdx +35 -33
- package/docs-site/zh/{guides → how-to}/authoring.mdx +35 -2
- package/docs-site/zh/{guides → how-to}/ci-integration.mdx +23 -12
- package/docs-site/zh/{guides → how-to}/connect-otel.mdx +6 -6
- package/docs-site/zh/{guides → how-to}/connect-your-agent.mdx +47 -21
- package/docs-site/zh/{guides → how-to}/custom-reports.mdx +34 -39
- package/docs-site/zh/{guides → how-to}/dataset-fanout.mdx +25 -3
- package/docs-site/zh/{guides → how-to}/experiments.mdx +12 -5
- package/docs-site/zh/how-to/publish-report.mdx +105 -0
- package/docs-site/zh/{guides → how-to}/reporters.mdx +2 -2
- package/docs-site/zh/{guides → how-to}/sandbox-agent.mdx +56 -7
- package/docs-site/zh/how-to/sandbox-providers.mdx +350 -0
- package/docs-site/zh/{guides → how-to}/scoring-guide.mdx +4 -4
- package/docs-site/zh/{guides → how-to}/viewing-results.mdx +82 -39
- package/docs-site/zh/{guides → how-to}/write-experiment.mdx +6 -4
- package/docs-site/zh/{guides → how-to}/write-send.mdx +30 -14
- package/docs-site/zh/index.mdx +24 -26
- package/docs-site/zh/introduction.mdx +8 -8
- package/docs-site/zh/reference/builtin-agents.mdx +32 -5
- package/docs-site/zh/reference/capabilities.mdx +8 -8
- package/docs-site/zh/reference/cli.mdx +40 -12
- package/docs-site/zh/reference/define-agent.mdx +58 -5
- package/docs-site/zh/reference/define-config.mdx +1 -1
- package/docs-site/zh/reference/define-eval.mdx +42 -9
- package/docs-site/zh/reference/events.mdx +3 -3
- package/docs-site/zh/reference/expect.mdx +26 -1
- package/docs-site/zh/{guides → reference}/official-adapters.mdx +32 -8
- package/docs-site/zh/{guides → reference}/report-components.mdx +45 -33
- package/docs-site/zh/{guides → reference}/results-data.mdx +21 -13
- package/docs-site/zh/troubleshooting/debug-sandbox.mdx +57 -0
- package/docs-site/zh/troubleshooting/debugging.mdx +212 -0
- package/docs-site/zh/{quickstart.mdx → tutorials/quickstart.mdx} +5 -17
- package/package.json +10 -2
- package/src/agents/ai-sdk-otel.test.ts +1 -0
- package/src/agents/ai-sdk.test.ts +3 -0
- package/src/agents/ai-sdk.ts +3 -0
- package/src/agents/bub-install-spec.test.ts +34 -0
- package/src/agents/bub-install-spec.ts +32 -0
- package/src/agents/bub.ts +31 -32
- package/src/agents/claude-code.test.ts +130 -9
- package/src/agents/claude-code.ts +76 -4
- package/src/agents/codex.test.ts +189 -40
- package/src/agents/codex.ts +155 -14
- package/src/agents/coding-cli-versions.test.ts +15 -0
- package/src/agents/coding-cli-versions.ts +3 -0
- package/src/agents/index.ts +13 -2
- package/src/agents/langgraph.test.ts +204 -0
- package/src/agents/langgraph.ts +495 -0
- package/src/agents/marketplace.ts +85 -0
- package/src/agents/native-config.test.ts +179 -0
- package/src/agents/native-config.ts +267 -0
- package/src/agents/openai-compat.test.ts +1 -0
- package/src/agents/openai-compat.ts +1 -1
- package/src/agents/openclaw.test.ts +31 -0
- package/src/agents/openclaw.ts +171 -0
- package/src/agents/plugin-config.test.ts +1 -0
- package/src/agents/sdk-streams.test.ts +79 -0
- package/src/agents/sdk-streams.ts +55 -10
- package/src/agents/skills.test.ts +1 -0
- package/src/agents/streaming.test.ts +3 -9
- package/src/agents/streaming.ts +2 -2
- package/src/agents/types.ts +71 -8
- package/src/agents/ui-message-stream.test.ts +3 -0
- package/src/cli.ts +446 -124
- package/src/context/context.test.ts +51 -12
- package/src/context/context.ts +162 -30
- package/src/context/session.test.ts +2 -1
- package/src/context/session.ts +115 -7
- package/src/context/types.ts +30 -12
- package/src/define.test.ts +13 -8
- package/src/define.ts +25 -4
- package/src/expect/index.ts +53 -23
- package/src/i18n/en.ts +81 -17
- package/src/i18n/zh-CN.ts +80 -17
- package/src/o11y/cost.test.ts +1 -0
- package/src/o11y/execution-tree.test.ts +1 -20
- package/src/o11y/otlp/mappers/claude-code.test.ts +1 -0
- package/src/o11y/otlp/parse.test.ts +1 -0
- package/src/o11y/otlp/turn-otel.test.ts +1 -0
- package/src/o11y/parsers/bub.test.ts +1 -0
- package/src/o11y/parsers/claude-code.test.ts +1 -34
- package/src/o11y/parsers/openclaw.test.ts +154 -0
- package/src/o11y/parsers/openclaw.ts +310 -0
- package/src/o11y/prices.json +746 -311
- package/src/o11y/tool-names.test.ts +1 -0
- package/src/o11y/types.ts +16 -2
- package/src/report/aggregate.ts +178 -61
- package/src/report/built-in/index.tsx +9 -0
- package/src/report/components.tsx +625 -279
- package/src/report/compute.ts +723 -491
- package/src/report/dual-render.test.tsx +741 -1024
- package/src/report/flag.ts +104 -12
- package/src/report/format.ts +32 -12
- package/src/report/index.ts +119 -46
- package/src/report/load.ts +3 -2
- package/src/report/locale.ts +136 -65
- package/src/report/metrics.ts +108 -25
- package/src/report/primitives.tsx +196 -45
- package/src/report/react/AttemptList.tsx +30 -43
- package/src/report/react/DeltaTable.tsx +63 -45
- package/src/report/react/EvalList.tsx +0 -0
- package/src/report/react/ExperimentComparison.tsx +73 -0
- package/src/report/react/ExperimentList.tsx +50 -32
- package/src/report/react/MetricBars.tsx +5 -4
- package/src/report/react/MetricLine.tsx +13 -8
- package/src/report/react/MetricMatrix.tsx +2 -2
- package/src/report/react/MetricScatter.tsx +86 -34
- package/src/report/react/MetricTable.tsx +4 -76
- package/src/report/react/ScopeSummary.tsx +86 -0
- package/src/report/react/Scoreboard.tsx +28 -10
- package/src/report/react/cell.tsx +2 -2
- package/src/report/react/chart-math.test.ts +85 -0
- package/src/report/react/chart-math.ts +101 -22
- package/src/report/react/enhance.js +89 -5
- package/src/report/react/fixtures.ts +114 -154
- package/src/report/react/index.tsx +24 -39
- package/src/report/react/render.test.tsx +138 -158
- package/src/report/react/styles.css +243 -82
- package/src/report/report.test.ts +779 -841
- package/src/report/report.ts +423 -41
- package/src/report/text/faces.ts +290 -193
- package/src/report/text/plot.ts +1 -1
- package/src/report/text/table.ts +44 -7
- package/src/report/tree.ts +362 -104
- package/src/report/types.ts +261 -271
- package/src/report/web.ts +63 -20
- package/src/results/annotated-source.test.ts +62 -9
- package/src/results/annotated-source.ts +64 -6
- package/src/results/attempt-evidence.test.ts +13 -11
- package/src/results/attempt-evidence.ts +20 -13
- package/src/results/attempt-source.ts +6 -3
- package/src/results/copy.ts +150 -60
- package/src/results/host-equivalence.test.ts +34 -20
- package/src/results/index.ts +12 -4
- package/src/results/locator.test.ts +1 -22
- package/src/results/open.ts +15 -5
- package/src/results/publish.ts +149 -0
- package/src/results/results.test.ts +89 -54
- package/src/results/select.ts +104 -34
- package/src/results/truncate.ts +90 -0
- package/src/results/types.ts +43 -14
- package/src/results/writer.ts +31 -13
- package/src/runner/attempt.test.ts +138 -7
- package/src/runner/attempt.ts +603 -104
- package/src/runner/discover.test.ts +47 -0
- package/src/runner/discover.ts +36 -2
- package/src/runner/eval-source.test.ts +1 -27
- package/src/runner/feedback/agent.test.ts +504 -0
- package/src/runner/feedback/agent.ts +409 -0
- package/src/runner/feedback/ci.test.ts +562 -0
- package/src/runner/feedback/ci.ts +401 -0
- package/src/runner/feedback/coordinator.test.ts +317 -0
- package/src/runner/feedback/coordinator.ts +397 -0
- package/src/runner/feedback/failure.ts +40 -0
- package/src/runner/feedback/human.test.ts +616 -0
- package/src/runner/feedback/human.ts +535 -0
- package/src/runner/feedback/index.ts +66 -0
- package/src/runner/feedback/io.ts +78 -0
- package/src/runner/feedback/profile.test.ts +50 -0
- package/src/runner/feedback/profile.ts +58 -0
- package/src/runner/feedback/reducer.test.ts +395 -0
- package/src/runner/feedback/reducer.ts +260 -0
- package/src/runner/feedback/renderer.ts +82 -0
- package/src/runner/feedback/sink.ts +203 -0
- package/src/runner/feedback/testing.ts +106 -0
- package/src/runner/ledger.test.ts +230 -0
- package/src/runner/ledger.ts +329 -0
- package/src/runner/report.test.ts +128 -3
- package/src/runner/report.ts +33 -9
- package/src/runner/reporters/artifacts.ts +8 -2
- package/src/runner/reporters/braintrust.test.ts +8 -7
- package/src/runner/reporters/braintrust.ts +9 -2
- package/src/runner/reporters/index.ts +2 -2
- package/src/runner/reporters/json.test.ts +162 -0
- package/src/runner/reporters/json.ts +35 -8
- package/src/runner/reporters/shared.ts +1 -5
- package/src/runner/run.test.ts +760 -3
- package/src/runner/run.ts +243 -37
- package/src/runner/sandbox-prep.ts +3 -42
- package/src/runner/timing.ts +158 -0
- package/src/runner/types.ts +518 -22
- package/src/sandbox/checkpoint.test.ts +55 -0
- package/src/sandbox/checkpoint.ts +29 -8
- package/src/sandbox/cli-commands.ts +407 -0
- package/src/sandbox/docker.ts +115 -16
- package/src/sandbox/e2b-agent-template.test.ts +56 -0
- package/src/sandbox/e2b-agent-template.ts +94 -0
- package/src/sandbox/e2b.ts +74 -9
- package/src/sandbox/errors.ts +111 -4
- package/src/sandbox/index.ts +2 -0
- package/src/sandbox/io-retry.test.ts +58 -0
- package/src/sandbox/io-retry.ts +45 -0
- package/src/sandbox/keep-registry.test.ts +86 -0
- package/src/sandbox/keep-registry.ts +142 -0
- package/src/sandbox/keep.ts +178 -0
- package/src/sandbox/paths.test.ts +1 -0
- package/src/sandbox/paths.ts +19 -8
- package/src/sandbox/registry.ts +20 -3
- package/src/sandbox/resolve.ts +76 -11
- package/src/sandbox/retry.test.ts +70 -0
- package/src/sandbox/retry.ts +46 -4
- package/src/sandbox/types.ts +44 -6
- package/src/sandbox/vercel.ts +43 -20
- package/src/scoring/collector.ts +60 -17
- package/src/scoring/coverage.ts +95 -0
- package/src/scoring/diff.ts +81 -0
- package/src/scoring/display.test.ts +121 -0
- package/src/scoring/display.ts +133 -0
- package/src/scoring/evidence.test.ts +189 -0
- package/src/scoring/judge.test.ts +142 -0
- package/src/scoring/judge.ts +15 -18
- package/src/scoring/scoped.ts +217 -50
- package/src/scoring/types.ts +117 -20
- package/src/scoring/verdict.ts +16 -4
- package/src/shared/aggregate.ts +8 -6
- package/src/shared/types.ts +31 -0
- package/src/show/compose.ts +50 -67
- package/src/show/index.ts +127 -56
- package/src/show/render.ts +662 -131
- package/src/show/report-host.test.ts +188 -0
- package/src/show/report-host.ts +375 -0
- package/src/show/show.test.ts +320 -54
- package/src/tty-line.ts +8 -26
- package/src/util.test.ts +1 -0
- package/src/util.ts +41 -0
- package/src/view/app/App.test.tsx +69 -0
- package/src/view/app/App.tsx +144 -48
- package/src/view/app/components/AttemptModal.tsx +423 -11
- package/src/view/app/components/CodeView.tsx +41 -14
- package/src/view/app/components/CopyControls.tsx +2 -2
- package/src/view/app/i18n.ts +37 -17
- package/src/view/app/lib/attempt-route.test.ts +1 -0
- package/src/view/app/lib/verdict.ts +7 -9
- package/src/view/app/main.tsx +13 -8
- package/src/view/app/pages/{RunsPage.tsx → AttemptsPage.tsx} +6 -6
- package/src/view/app/types.ts +4 -1
- package/src/view/artifact-serving.test.ts +2 -1
- package/src/view/client-dist/app.css +1 -1
- package/src/view/client-dist/app.js +17 -17
- package/src/view/data.test.ts +10 -3
- package/src/view/data.ts +155 -49
- package/src/view/index.ts +56 -41
- package/src/view/server.ts +37 -15
- package/src/view/shared/types.ts +34 -5
- package/src/view/styles.css +227 -0
- package/src/view/view-report.test.ts +167 -62
- package/dist/report/built-ins/experiment-comparison.d.ts +0 -1
- package/dist/report/built-ins/experiment-comparison.js +0 -13
- package/dist/report/built-ins/index.d.ts +0 -1
- package/dist/report/built-ins/index.js +0 -2
- package/dist/report/react/GroupSummary.d.ts +0 -8
- package/dist/report/react/GroupSummary.js +0 -8
- package/dist/report/react/RunOverview.d.ts +0 -8
- package/dist/report/react/RunOverview.js +0 -12
- package/docs-site/zh/example/ai-agent-application.mdx +0 -152
- package/docs-site/zh/example/claude-code-codex-plugin.mdx +0 -167
- package/docs-site/zh/example/claude-code-codex-skill.mdx +0 -152
- package/docs-site/zh/example/showcase.mdx +0 -39
- package/docs-site/zh/guides/publish-report.mdx +0 -91
- package/docs-site/zh/guides/sandbox-providers.mdx +0 -102
- package/src/report/built-in-user-parity.test.tsx +0 -640
- package/src/report/built-ins/experiment-comparison.tsx +0 -19
- package/src/report/built-ins/index.ts +0 -2
- package/src/report/react/GroupSummary.tsx +0 -66
- package/src/report/react/RunOverview.tsx +0 -109
- package/src/runner/reporters/console.ts +0 -70
- package/src/runner/reporters/live.test.ts +0 -56
- package/src/runner/reporters/live.ts +0 -247
- package/src/runner/reporters/quiet.test.ts +0 -66
- package/src/runner/reporters/quiet.ts +0 -49
- package/src/runner/reporters/table.ts +0 -277
- /package/docs-site/zh/{example/tier1-ai-sdk-v7.mdx → examples/integrations/ai-sdk-v7.mdx} +0 -0
- /package/docs-site/zh/{example/tier1-claude-sdk.mdx → examples/integrations/claude-sdk.mdx} +0 -0
- /package/docs-site/zh/{example/tier1-codex-sdk.mdx → examples/integrations/codex-sdk.mdx} +0 -0
- /package/docs-site/zh/{example/tier1-langgraph.mdx → examples/integrations/langgraph.mdx} +0 -0
- /package/docs-site/zh/{example/tier1-pi-sdk.mdx → examples/integrations/pi-sdk.mdx} +0 -0
- /package/docs-site/zh/{guides → how-to}/fixtures.mdx +0 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// cases: docs/engineering/unit-tests/experiments-runner/cases.md
|
|
2
|
+
// coordinator.ts 的行为测试:全部使用 testing.ts 的假 FeedbackIO,不 monkey-patch 全局
|
|
3
|
+
// process/Date/setInterval —— coordinator 的关闭路径(onRendererError 的兜底)刻意走真实
|
|
4
|
+
// `src/tty-line.ts`(允许保留裸写的「feedback sink 自己」),这里只验证队列在 renderer 抛错
|
|
5
|
+
// 后仍然继续正常处理后续事件,不对那条兜底裸写本身断言,避免整份测试沾上 monkey-patch 依赖。
|
|
6
|
+
//
|
|
7
|
+
// coordinator 内部投递用真实 Promise 微任务队列(SerialQueue),不挂在注入的 fake clock 上 ——
|
|
8
|
+
// 断言前必须 flush() 一次(等一个真实宏任务,保证所有链式微任务都已跑完)。sink.ts 的活跃
|
|
9
|
+
// coordinator 是模块级栈:每个调用 start() 的测试都必须以 finish() 收尾,否则会把自己遗留在
|
|
10
|
+
// 栈里污染后续测试对 reportDiagnostic()/reportActivity() 路由目标的断言 —— afterEach 用
|
|
11
|
+
// activeFeedbackSinkCount() 兜底校验,忘记清理会在下一个测试之前就报错定位到具体哪个测试。
|
|
12
|
+
|
|
13
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
14
|
+
import { createFeedbackCoordinator } from "./coordinator.ts";
|
|
15
|
+
import { createFakeFeedbackIO } from "./testing.ts";
|
|
16
|
+
import { activeFeedbackSinkCount, reportActivity, reportDiagnostic } from "./sink.ts";
|
|
17
|
+
import type { FeedbackRenderer } from "./renderer.ts";
|
|
18
|
+
import type {
|
|
19
|
+
AttemptLifecycleEvent,
|
|
20
|
+
DurableFeedbackEvent,
|
|
21
|
+
FeedbackTickEvent,
|
|
22
|
+
RunCompletion,
|
|
23
|
+
RunFeedbackPlan,
|
|
24
|
+
RunSummary,
|
|
25
|
+
} from "../types.ts";
|
|
26
|
+
|
|
27
|
+
/** 等一个真实宏任务:保证 SerialQueue 目前为止链上的全部微任务(不管链多深)都已经跑完。 */
|
|
28
|
+
function flush(): Promise<void> {
|
|
29
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function plan(overrides: Partial<RunFeedbackPlan["shape"]> = {}): RunFeedbackPlan {
|
|
33
|
+
return {
|
|
34
|
+
shape: { evals: 1, configs: 1, totalRuns: 1, maxConcurrency: 1, ...overrides },
|
|
35
|
+
reused: 0,
|
|
36
|
+
reusedFailures: [],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function summary(): RunSummary {
|
|
41
|
+
return {
|
|
42
|
+
agent: "codex",
|
|
43
|
+
startedAt: "2026-07-13T00:00:00.000Z",
|
|
44
|
+
completedAt: "2026-07-13T00:00:01.000Z",
|
|
45
|
+
passed: 1,
|
|
46
|
+
failed: 0,
|
|
47
|
+
skipped: 0,
|
|
48
|
+
errored: 0,
|
|
49
|
+
durationMs: 1000,
|
|
50
|
+
results: [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function completion(): RunCompletion {
|
|
55
|
+
return { status: "complete", unstarted: 0, earlyExitUnstarted: 0, reporterErrors: [] };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 记录每次调用(按发生顺序拼成一条 tag),供断言 clear→append→redraw 的原子顺序。
|
|
59
|
+
* 可选 throwOn 让某个 durable 事件的 appendDurable 抛错,用来验证队列的容错性。 */
|
|
60
|
+
function recordingRenderer(opts: { throwOn?: (event: DurableFeedbackEvent) => boolean } = {}) {
|
|
61
|
+
const calls: string[] = [];
|
|
62
|
+
const renderer: FeedbackRenderer = {
|
|
63
|
+
clearDynamic() {
|
|
64
|
+
calls.push("clear");
|
|
65
|
+
},
|
|
66
|
+
appendDurable(event: DurableFeedbackEvent) {
|
|
67
|
+
if (opts.throwOn?.(event)) throw new Error(`boom:${event.type}`);
|
|
68
|
+
calls.push(`durable:${event.type}`);
|
|
69
|
+
},
|
|
70
|
+
redrawDynamic() {
|
|
71
|
+
calls.push("redraw");
|
|
72
|
+
},
|
|
73
|
+
activity(text: string) {
|
|
74
|
+
calls.push(`activity:${text}`);
|
|
75
|
+
},
|
|
76
|
+
onTick(event: FeedbackTickEvent) {
|
|
77
|
+
calls.push(`tick:${event.elapsedMs}`);
|
|
78
|
+
},
|
|
79
|
+
onLifecycle(event: AttemptLifecycleEvent) {
|
|
80
|
+
calls.push(`lifecycle:${event.type}`);
|
|
81
|
+
},
|
|
82
|
+
close() {
|
|
83
|
+
calls.push("close");
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
return { calls, renderer };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
afterEach(() => {
|
|
90
|
+
// 每个 start() 过的 coordinator 都应该在测试内 finish() 掉;这里兜底校验没有测试忘记清理
|
|
91
|
+
// 而把自己遗留在 sink.ts 的活跃栈里(会静默污染下一个测试对 reportXxx() 路由目标的断言)。
|
|
92
|
+
expect(activeFeedbackSinkCount()).toBe(0);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("createFeedbackCoordinator: durable 事件的 clear→append→redraw 顺序", () => {
|
|
96
|
+
it("start() 立即以 clear→append(plan)→redraw 的顺序调用 renderer,并更新 state", async () => {
|
|
97
|
+
const { io } = createFakeFeedbackIO();
|
|
98
|
+
const { calls, renderer } = recordingRenderer();
|
|
99
|
+
const coordinator = createFeedbackCoordinator({ profile: "human", renderer, io });
|
|
100
|
+
coordinator.start(plan({ totalRuns: 5 }));
|
|
101
|
+
await flush();
|
|
102
|
+
expect(calls).toEqual(["clear", "durable:plan", "redraw"]);
|
|
103
|
+
expect(coordinator.state).toMatchObject({ total: 5, queued: 5 });
|
|
104
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("diagnostic() 按 emit() 的原子顺序处理,即便 renderer 方法是异步的也不交错", async () => {
|
|
108
|
+
const { io } = createFakeFeedbackIO();
|
|
109
|
+
const calls: string[] = [];
|
|
110
|
+
const renderer: FeedbackRenderer = {
|
|
111
|
+
async clearDynamic() {
|
|
112
|
+
await Promise.resolve();
|
|
113
|
+
calls.push("clear");
|
|
114
|
+
},
|
|
115
|
+
async appendDurable(event) {
|
|
116
|
+
await Promise.resolve();
|
|
117
|
+
calls.push(`durable:${event.type}`);
|
|
118
|
+
},
|
|
119
|
+
async redrawDynamic() {
|
|
120
|
+
await Promise.resolve();
|
|
121
|
+
calls.push("redraw");
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const coordinator = createFeedbackCoordinator({ profile: "human", renderer, io });
|
|
125
|
+
coordinator.start(plan());
|
|
126
|
+
coordinator.diagnostic({ key: "a", severity: "warning", message: "first" });
|
|
127
|
+
coordinator.diagnostic({ key: "b", severity: "warning", message: "second" });
|
|
128
|
+
await coordinator.stopDynamic();
|
|
129
|
+
expect(calls).toEqual([
|
|
130
|
+
"clear",
|
|
131
|
+
"durable:plan",
|
|
132
|
+
"redraw",
|
|
133
|
+
"clear",
|
|
134
|
+
"durable:diagnostic",
|
|
135
|
+
"redraw",
|
|
136
|
+
"clear",
|
|
137
|
+
"durable:diagnostic",
|
|
138
|
+
"redraw",
|
|
139
|
+
"clear", // stopDynamic() 收尾的无条件再清一次
|
|
140
|
+
]);
|
|
141
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("同一 key 的 diagnostic 去重进 state,但仍逐次转发给 renderer(是否折叠展示由 renderer 决定)", async () => {
|
|
145
|
+
const { io } = createFakeFeedbackIO();
|
|
146
|
+
const { calls, renderer } = recordingRenderer();
|
|
147
|
+
const coordinator = createFeedbackCoordinator({ profile: "agent", renderer, io });
|
|
148
|
+
coordinator.start(plan());
|
|
149
|
+
coordinator.diagnostic({ key: "memory-warmup-degraded", severity: "warning", message: "cold index (1)" });
|
|
150
|
+
coordinator.diagnostic({ key: "memory-warmup-degraded", severity: "warning", message: "cold index (2)" });
|
|
151
|
+
coordinator.diagnostic({ key: "memory-warmup-degraded", severity: "warning", message: "cold index (3)" });
|
|
152
|
+
await flush();
|
|
153
|
+
expect(coordinator.state.diagnostics).toHaveLength(1);
|
|
154
|
+
expect(coordinator.state.diagnostics[0]).toMatchObject({ key: "memory-warmup-degraded", count: 3 });
|
|
155
|
+
expect(calls.filter((c) => c === "durable:diagnostic")).toHaveLength(3);
|
|
156
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("activity() 不进入 state.diagnostics/failures,但同样走 clear→activity→redraw", async () => {
|
|
160
|
+
const { io } = createFakeFeedbackIO();
|
|
161
|
+
const { calls, renderer } = recordingRenderer();
|
|
162
|
+
const coordinator = createFeedbackCoordinator({ profile: "human", renderer, io });
|
|
163
|
+
coordinator.start(plan());
|
|
164
|
+
coordinator.activity("pulling docker image node:24-slim...");
|
|
165
|
+
await flush();
|
|
166
|
+
expect(coordinator.state.diagnostics).toEqual([]);
|
|
167
|
+
expect(coordinator.state.failures).toEqual([]);
|
|
168
|
+
expect(calls.slice(-3)).toEqual(["clear", "activity:pulling docker image node:24-slim...", "redraw"]);
|
|
169
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("renderer 在某个 durable 事件上抛错不会中断队列,后续事件照常按完整顺序处理", async () => {
|
|
173
|
+
const { io } = createFakeFeedbackIO();
|
|
174
|
+
const { calls, renderer } = recordingRenderer({ throwOn: (e) => e.type === "diagnostic" });
|
|
175
|
+
const coordinator = createFeedbackCoordinator({ profile: "human", renderer, io });
|
|
176
|
+
coordinator.start(plan());
|
|
177
|
+
coordinator.diagnostic({ key: "boom", severity: "warning", message: "x" });
|
|
178
|
+
coordinator.interrupted();
|
|
179
|
+
await coordinator.stopDynamic();
|
|
180
|
+
// plan 正常;diagnostic 那次 clear 之后抛错(所以没有 "durable:diagnostic"、没有紧跟的
|
|
181
|
+
// "redraw"),但下一个事件(interrupted)仍然拿到完整的 clear→append→redraw。
|
|
182
|
+
expect(calls).toEqual([
|
|
183
|
+
"clear",
|
|
184
|
+
"durable:plan",
|
|
185
|
+
"redraw",
|
|
186
|
+
"clear",
|
|
187
|
+
"clear",
|
|
188
|
+
"durable:interrupted",
|
|
189
|
+
"redraw",
|
|
190
|
+
"clear",
|
|
191
|
+
]);
|
|
192
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
describe("createFeedbackCoordinator: tick 与 heartbeat 节奏", () => {
|
|
197
|
+
it("tick 定时器按注入的 clock 周期性触发,elapsedMs 相对 start() 时刻计算", async () => {
|
|
198
|
+
const fake = createFakeFeedbackIO();
|
|
199
|
+
const { calls, renderer } = recordingRenderer();
|
|
200
|
+
const coordinator = createFeedbackCoordinator({ profile: "agent", renderer, io: fake.io, tickIntervalMs: 100 });
|
|
201
|
+
coordinator.start(plan());
|
|
202
|
+
fake.advance(350);
|
|
203
|
+
await flush();
|
|
204
|
+
const ticks = calls.filter((c) => c.startsWith("tick:"));
|
|
205
|
+
expect(ticks).toEqual(["tick:100", "tick:200", "tick:300"]);
|
|
206
|
+
expect(coordinator.state.elapsedMs).toBe(300);
|
|
207
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("stopDynamic() 之后不再有 tick 触发(定时器已清)", async () => {
|
|
211
|
+
const fake = createFakeFeedbackIO();
|
|
212
|
+
const { calls, renderer } = recordingRenderer();
|
|
213
|
+
const coordinator = createFeedbackCoordinator({ profile: "ci", renderer, io: fake.io, tickIntervalMs: 100 });
|
|
214
|
+
coordinator.start(plan());
|
|
215
|
+
fake.advance(150);
|
|
216
|
+
await coordinator.stopDynamic();
|
|
217
|
+
expect(fake.activeTimerCount()).toBe(0);
|
|
218
|
+
const ticksBefore = calls.filter((c) => c.startsWith("tick:")).length;
|
|
219
|
+
fake.advance(1000); // 就算时钟继续走,也不会再触发(定时器已被 clearInterval)
|
|
220
|
+
const ticksAfter = calls.filter((c) => c.startsWith("tick:")).length;
|
|
221
|
+
expect(ticksAfter).toBe(ticksBefore);
|
|
222
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe("createFeedbackCoordinator: 关闭顺序", () => {
|
|
227
|
+
it("stopDynamic() 之后,diagnostic()/activity() 仍会 append,但不再 clear/redraw", async () => {
|
|
228
|
+
const { io } = createFakeFeedbackIO();
|
|
229
|
+
const { calls, renderer } = recordingRenderer();
|
|
230
|
+
const coordinator = createFeedbackCoordinator({ profile: "human", renderer, io });
|
|
231
|
+
coordinator.start(plan());
|
|
232
|
+
await coordinator.stopDynamic();
|
|
233
|
+
calls.length = 0; // 只看 stopDynamic 之后的行为(此时已经排空过一次队列,重置是安全的)
|
|
234
|
+
coordinator.diagnostic({ key: "late", severity: "warning", message: "reporter 收尾期间的诊断" });
|
|
235
|
+
coordinator.activity("late activity");
|
|
236
|
+
await flush();
|
|
237
|
+
expect(calls).toEqual(["durable:diagnostic", "activity:late activity"]);
|
|
238
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("finish() 追加 summary/saved、调用 renderer.close(),之后不再接受任何输出", async () => {
|
|
242
|
+
const { io } = createFakeFeedbackIO();
|
|
243
|
+
const { calls, renderer } = recordingRenderer();
|
|
244
|
+
const coordinator = createFeedbackCoordinator({ profile: "ci", renderer, io });
|
|
245
|
+
coordinator.start(plan());
|
|
246
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [".niceeval/ci/2026"] });
|
|
247
|
+
expect(calls).toContain("durable:summary");
|
|
248
|
+
expect(calls).toContain("durable:saved");
|
|
249
|
+
expect(calls[calls.length - 1]).toBe("close");
|
|
250
|
+
|
|
251
|
+
const before = calls.length;
|
|
252
|
+
coordinator.diagnostic({ key: "after-finish", severity: "warning", message: "should be dropped" });
|
|
253
|
+
coordinator.activity("also dropped");
|
|
254
|
+
await flush();
|
|
255
|
+
expect(calls.length).toBe(before); // finish() 之后完全不再调用 renderer
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it("finish() 内部会先跑 stopDynamic(顺序:停 tick → 清 dashboard → summary/saved → close)", async () => {
|
|
259
|
+
const fake = createFakeFeedbackIO();
|
|
260
|
+
const { calls, renderer } = recordingRenderer();
|
|
261
|
+
const coordinator = createFeedbackCoordinator({ profile: "human", renderer, io: fake.io, tickIntervalMs: 50 });
|
|
262
|
+
coordinator.start(plan());
|
|
263
|
+
await flush(); // 让 plan 的 clear→append→redraw 先跑完,再清空追踪数组只看收尾阶段
|
|
264
|
+
calls.length = 0;
|
|
265
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
266
|
+
// 第一个 "clear" 来自 stopDynamic() 收尾清空;finish() 时 phase 已经是 dynamicStopped,
|
|
267
|
+
// summary/saved 因此只 append、不再 clear/redraw。
|
|
268
|
+
expect(calls).toEqual(["clear", "durable:summary", "durable:saved", "close"]);
|
|
269
|
+
expect(fake.activeTimerCount()).toBe(0);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("start() 重复调用抛错;stopDynamic()/diagnostic() 在 start() 之前调用抛错", async () => {
|
|
273
|
+
const { io } = createFakeFeedbackIO();
|
|
274
|
+
const { renderer } = recordingRenderer();
|
|
275
|
+
const coordinator = createFeedbackCoordinator({ profile: "human", renderer, io });
|
|
276
|
+
expect(() => coordinator.diagnostic({ key: "x", severity: "warning", message: "x" })).toThrow();
|
|
277
|
+
await expect(coordinator.stopDynamic()).rejects.toThrow();
|
|
278
|
+
coordinator.start(plan());
|
|
279
|
+
expect(() => coordinator.start(plan())).toThrow();
|
|
280
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
describe("sink.ts 集成:reportDiagnostic()/reportActivity() 只在 coordinator 活跃期间转发给它", () => {
|
|
285
|
+
it("start() 之前调用落回 bootstrap,不触碰这个 coordinator 的 renderer", async () => {
|
|
286
|
+
const { io } = createFakeFeedbackIO();
|
|
287
|
+
const { calls, renderer } = recordingRenderer();
|
|
288
|
+
const coordinator = createFeedbackCoordinator({ profile: "agent", renderer, io });
|
|
289
|
+
reportDiagnostic({ key: "before-start", severity: "warning", message: "x" });
|
|
290
|
+
reportActivity("before-start activity");
|
|
291
|
+
expect(calls).toEqual([]);
|
|
292
|
+
// 清理:即便这个 coordinator 从未真正 start(),afterEach 只校验活跃栈计数,不要求
|
|
293
|
+
// 每个测试局部变量都必须走完整生命周期 —— 这里不 start() 就不需要 finish()。
|
|
294
|
+
void coordinator;
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("start() 之后,sink.ts 的便捷函数转发给活跃 coordinator;finish() 之后落回 bootstrap", async () => {
|
|
298
|
+
const { io } = createFakeFeedbackIO();
|
|
299
|
+
const { calls, renderer } = recordingRenderer();
|
|
300
|
+
const coordinator = createFeedbackCoordinator({ profile: "ci", renderer, io });
|
|
301
|
+
coordinator.start(plan());
|
|
302
|
+
expect(activeFeedbackSinkCount()).toBe(1);
|
|
303
|
+
await flush();
|
|
304
|
+
calls.length = 0;
|
|
305
|
+
reportDiagnostic({ key: "via-sink", severity: "warning", message: "routed" });
|
|
306
|
+
reportActivity("also routed");
|
|
307
|
+
await flush();
|
|
308
|
+
expect(calls).toEqual(["clear", "durable:diagnostic", "redraw", "clear", "activity:also routed", "redraw"]);
|
|
309
|
+
|
|
310
|
+
await coordinator.finish({ summary: summary(), completion: completion(), paths: [] });
|
|
311
|
+
expect(activeFeedbackSinkCount()).toBe(0); // finish() 摘掉自己,不遗留在活跃栈里
|
|
312
|
+
|
|
313
|
+
calls.length = 0;
|
|
314
|
+
reportDiagnostic({ key: "after-finish", severity: "warning", message: "not routed" });
|
|
315
|
+
expect(calls).toEqual([]); // 落回 bootstrap,不再触碰这个已经 finish 的 coordinator
|
|
316
|
+
});
|
|
317
|
+
});
|