
















@@ -29,6 +29,7 @@ import type { TaskFlowRecord } from "./task-flow-registry.types.js";
2929import {
3030cancelTaskById,
3131createTaskRecord as createTaskRecordOrNull,
32+finalizeTaskRunByRunId,
3233findLatestTaskForRelatedSessionKey,
3334findTaskByRunId,
3435getTaskById,
@@ -41,7 +42,6 @@ import {
4142maybeDeliverTaskTerminalUpdate,
4243markTaskRunningByRunId,
4344markTaskTerminalById,
44-markTaskTerminalByRunId,
4545recordTaskProgressByRunId,
4646reloadTaskRegistryFromStore,
4747resetTaskRegistryControlRuntimeForTests,
@@ -50,8 +50,6 @@ import {
5050resolveTaskForLookupToken,
5151setTaskRegistryControlRuntimeForTests,
5252setTaskRegistryDeliveryRuntimeForTests,
53-setTaskProgressById,
54-setTaskTimingById,
5553updateTaskNotifyPolicyById,
5654} from "./task-registry.js";
5755import {
@@ -600,7 +598,7 @@ describe("task-registry", () => {
600598aborted: true,
601599},
602600});
603-markTaskTerminalByRunId({
601+finalizeTaskRunByRunId({
604602runId: "run-timeout-then-success",
605603runtime: "cli",
606604status: "succeeded",
@@ -771,14 +769,14 @@ describe("task-registry", () => {
771769startedAt: 100,
772770});
773771774-markTaskTerminalByRunId({
772+finalizeTaskRunByRunId({
775773runId: "run-fail-then-success",
776774runtime: "cli",
777775status: "failed",
778776endedAt: 200,
779777error: "delivery failed",
780778});
781-markTaskTerminalByRunId({
779+finalizeTaskRunByRunId({
782780runId: "run-fail-then-success",
783781runtime: "cli",
784782status: "succeeded",
@@ -818,7 +816,7 @@ describe("task-registry", () => {
818816endedAt: 200,
819817},
820818});
821-markTaskTerminalByRunId({
819+finalizeTaskRunByRunId({
822820runId: "run-success-then-fail",
823821runtime: "cli",
824822status: "failed",
@@ -1725,8 +1723,8 @@ describe("task-registry", () => {
17251723startedAt: 100,
17261724});
172717251728-setTaskProgressById({
1729-taskId: findTaskByRunId("run-detail-leak")!.taskId,
1726+recordTaskProgressByRunId({
1727+runId: "run-detail-leak",
17301728progressSummary:
17311729"I am loading the local session context and checking helper command availability before writing the file.",
17321730});
@@ -2272,9 +2270,6 @@ describe("task-registry", () => {
22722270task: "Missing child",
22732271status: "running",
22742272deliveryStatus: "pending",
2275-});
2276-setTaskTimingById({
2277-taskId: task.taskId,
22782273lastEventAt: Date.now() - 10 * 60_000,
22792274});
22802275@@ -2337,9 +2332,6 @@ describe("task-registry", () => {
23372332task: "Missing child",
23382333status: "running",
23392334deliveryStatus: "pending",
2340-});
2341-setTaskTimingById({
2342-taskId: task.taskId,
23432335lastEventAt: now - 10 * 60_000,
23442336});
23452337@@ -2381,9 +2373,6 @@ describe("task-registry", () => {
23812373status: "running",
23822374deliveryStatus: "not_applicable",
23832375notifyPolicy: "silent",
2384-});
2385-setTaskTimingById({
2386-taskId: task.taskId,
23872376lastEventAt: now - 10 * 60_000,
23882377});
23892378@@ -2416,9 +2405,6 @@ describe("task-registry", () => {
24162405status: "running",
24172406deliveryStatus: "not_applicable",
24182407notifyPolicy: "silent",
2419-});
2420-setTaskTimingById({
2421-taskId: task.taskId,
24222408lastEventAt: now - 31 * 60_000,
24232409});
24242410@@ -2451,9 +2437,6 @@ describe("task-registry", () => {
24512437status: "running",
24522438deliveryStatus: "not_applicable",
24532439notifyPolicy: "silent",
2454-});
2455-setTaskTimingById({
2456-taskId: task.taskId,
24572440lastEventAt: now - 31 * 60_000,
24582441});
24592442@@ -2486,9 +2469,12 @@ describe("task-registry", () => {
24862469task: "Old ACP task",
24872470status: "succeeded",
24882471deliveryStatus: "delivered",
2472+lastEventAt: now - 60_000,
24892473});
2490-setTaskTimingById({
2491-taskId: task.taskId,
2474+finalizeTaskRunByRunId({
2475+runId: "run-terminal-acp-oneshot",
2476+runtime: "acp",
2477+status: "succeeded",
24922478endedAt: now - 60_000,
24932479lastEventAt: now - 60_000,
24942480});
@@ -2636,9 +2622,12 @@ describe("task-registry", () => {
26362622task: "Old persistent ACP task",
26372623status: "failed",
26382624deliveryStatus: "failed",
2625+lastEventAt: now - 60_000,
26392626});
2640-setTaskTimingById({
2641-taskId: task.taskId,
2627+finalizeTaskRunByRunId({
2628+runId: "run-terminal-acp-persistent",
2629+runtime: "acp",
2630+status: "failed",
26422631endedAt: now - 60_000,
26432632lastEventAt: now - 60_000,
26442633});
@@ -2688,9 +2677,12 @@ describe("task-registry", () => {
26882677task: "Thread-bound ACP session",
26892678status: "succeeded",
26902679deliveryStatus: "delivered",
2680+lastEventAt: now - 60_000,
26912681});
2692-setTaskTimingById({
2693-taskId: task.taskId,
2682+finalizeTaskRunByRunId({
2683+runId: "run-terminal-acp-bound",
2684+runtime: "acp",
2685+status: "succeeded",
26942686endedAt: now - 60_000,
26952687lastEventAt: now - 60_000,
26962688});
@@ -2824,7 +2816,7 @@ describe("task-registry", () => {
28242816await withTaskRegistryTempDir(async () => {
28252817resetTaskRegistryMemoryForTest();
282628182827-const task = createTaskRecord({
2819+createTaskRecord({
28282820runtime: "cli",
28292821ownerKey: "agent:main:main",
28302822scopeKind: "session",
@@ -2834,9 +2826,12 @@ describe("task-registry", () => {
28342826status: "succeeded",
28352827deliveryStatus: "not_applicable",
28362828startedAt: Date.now() - 9 * 24 * 60 * 60_000,
2829+lastEventAt: Date.now() - 8 * 24 * 60 * 60_000,
28372830});
2838-setTaskTimingById({
2839-taskId: task.taskId,
2831+finalizeTaskRunByRunId({
2832+runId: "run-prune",
2833+runtime: "cli",
2834+status: "succeeded",
28402835endedAt: Date.now() - 8 * 24 * 60 * 60_000,
28412836lastEventAt: Date.now() - 8 * 24 * 60 * 60_000,
28422837});
@@ -2916,9 +2911,6 @@ describe("task-registry", () => {
29162911task: "Missing child",
29172912status: "running",
29182913deliveryStatus: "pending",
2919-});
2920-setTaskTimingById({
2921-taskId: task.taskId,
29222914lastEventAt: now - 10 * 60_000,
29232915});
29242916@@ -3147,8 +3139,8 @@ describe("task-registry", () => {
31473139});
3148314031493141nowSpy.mockReturnValue(1_700_000_001_000);
3150-setTaskTimingById({
3151-taskId: task.taskId,
3142+markTaskRunningByRunId({
3143+runId: "run-backdated-update",
31523144startedAt: 1_699_999_998_000,
31533145lastEventAt: 1_699_999_998_500,
31543146});
@@ -3220,7 +3212,7 @@ describe("task-registry", () => {
32203212},
32213213});
322232143223-const staleTask = createTaskRecord({
3215+createTaskRecord({
32243216runtime: "cli",
32253217ownerKey: "agent:main:main",
32263218scopeKind: "session",
@@ -3230,9 +3222,6 @@ describe("task-registry", () => {
32303222status: "running",
32313223deliveryStatus: "pending",
32323224notifyPolicy: "silent",
3233-});
3234-setTaskTimingById({
3235-taskId: staleTask.taskId,
32363225startedAt: now - 60_000,
32373226lastEventAt: now - 60_000,
32383227});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。