From fc6a02ac1ad2cf5a25b66cc1930ab3bd0d7e7945 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Fri, 12 Jun 2026 14:08:02 +0800 Subject: [PATCH] fix(taskState): report artifact fallback as unknown evidence --- dist/src/taskState.js | 15 ++++++++++----- src/taskState.test.ts | 18 +++++++++++------- src/taskState.ts | 15 ++++++++++----- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/dist/src/taskState.js b/dist/src/taskState.js index 91f3868..35fe992 100644 --- a/dist/src/taskState.js +++ b/dist/src/taskState.js @@ -165,9 +165,10 @@ export async function getXWorkmateTaskSnapshot(input) { : undefined; if (exported?.artifacts.length) { return { - success: true, - status: "completed", - taskStatus: "succeeded", + success: false, + status: "unknown", + taskStatus: "unknown", + evidence: "artifacts_present", mode: "gateway-chat", mapping, appThreadKey: mapping?.appThreadKey ?? appThreadKey, @@ -177,7 +178,7 @@ export async function getXWorkmateTaskSnapshot(input) { task: { taskId: taskId || runId, runId, - status: "succeeded", + status: "unknown", source: "artifact_fallback", }, expectedArtifactDirs: mapping?.expectedArtifactDirs ?? [], @@ -186,9 +187,11 @@ export async function getXWorkmateTaskSnapshot(input) { remoteWorkspaceRefKind: exported.remoteWorkspaceRefKind, scopeKind: exported.scopeKind, artifacts: exported.artifacts, + constraintSatisfied: exported.constraintSatisfied, + missingRequiredExtensions: exported.missingRequiredExtensions, warnings: [ ...exported.warnings, - `Native OpenClaw task record was unavailable for ${openclawSessionKey}; resolved from task artifacts.`, + `Native OpenClaw task record was unavailable for ${openclawSessionKey}; artifacts are present but task status is unknown.`, ], artifactCount: exported.artifacts.length, }; @@ -217,6 +220,8 @@ export async function getXWorkmateTaskSnapshot(input) { remoteWorkspaceRefKind: exported?.remoteWorkspaceRefKind, scopeKind: exported?.scopeKind, artifacts: exported?.artifacts ?? [], + constraintSatisfied: exported?.constraintSatisfied, + missingRequiredExtensions: exported?.missingRequiredExtensions, warnings: exported?.warnings ?? [], artifactCount: exported?.artifacts.length ?? 0, }; diff --git a/src/taskState.test.ts b/src/taskState.test.ts index 2ae6ba3..1eddab0 100644 --- a/src/taskState.test.ts +++ b/src/taskState.test.ts @@ -166,14 +166,14 @@ describe("xworkmate task state mapping", () => { }); }); - it("resolves completed snapshot from task artifacts when native task record is unavailable", async () => { + it("reports unknown evidence from task artifacts when native task record is unavailable", async () => { const workspaceDir = await createWorkspaceFixture(); const appThreadKey = "draft:sample-task"; const openclawSessionKey = "agent:main:draft:sample-task"; const runId = "turn-sample"; const artifactDir = path.join(workspaceDir, "tasks", "agent_main_draft_sample-task", runId); await fs.mkdir(artifactDir, { recursive: true }); - await fs.writeFile(path.join(artifactDir, "report.md"), "# Report\n", "utf8"); + await fs.writeFile(path.join(artifactDir, "series.config.json"), "{}\n", "utf8"); const { api } = createApiFixture({}, { workspaceDir }); await recordXWorkmateSessionMapping({ @@ -196,21 +196,25 @@ describe("xworkmate task state mapping", () => { }); expect(result).toMatchObject({ - success: true, - status: "completed", - taskStatus: "succeeded", + success: false, + status: "unknown", + taskStatus: "unknown", + evidence: "artifacts_present", openclawSessionKey, runId, task: { source: "artifact_fallback", + status: "unknown", }, artifacts: [ { - relativePath: "report.md", - contentType: "text/markdown", + relativePath: "series.config.json", + contentType: "application/json", }, ], + artifactCount: 1, }); + expect((result.warnings as string[]).some((entry) => entry.includes("task status is unknown"))).toBe(true); }); it("returns no_native_task_record when neither native task record nor task artifacts exist", async () => { diff --git a/src/taskState.ts b/src/taskState.ts index b796e9b..4c037de 100644 --- a/src/taskState.ts +++ b/src/taskState.ts @@ -260,9 +260,10 @@ export async function getXWorkmateTaskSnapshot(input: { : undefined; if (exported?.artifacts.length) { return { - success: true, - status: "completed", - taskStatus: "succeeded", + success: false, + status: "unknown", + taskStatus: "unknown", + evidence: "artifacts_present", mode: "gateway-chat", mapping, appThreadKey: mapping?.appThreadKey ?? appThreadKey, @@ -272,7 +273,7 @@ export async function getXWorkmateTaskSnapshot(input: { task: { taskId: taskId || runId, runId, - status: "succeeded", + status: "unknown", source: "artifact_fallback", }, expectedArtifactDirs: mapping?.expectedArtifactDirs ?? [], @@ -281,9 +282,11 @@ export async function getXWorkmateTaskSnapshot(input: { remoteWorkspaceRefKind: exported.remoteWorkspaceRefKind, scopeKind: exported.scopeKind, artifacts: exported.artifacts, + constraintSatisfied: exported.constraintSatisfied, + missingRequiredExtensions: exported.missingRequiredExtensions, warnings: [ ...exported.warnings, - `Native OpenClaw task record was unavailable for ${openclawSessionKey}; resolved from task artifacts.`, + `Native OpenClaw task record was unavailable for ${openclawSessionKey}; artifacts are present but task status is unknown.`, ], artifactCount: exported.artifacts.length, }; @@ -320,6 +323,8 @@ export async function getXWorkmateTaskSnapshot(input: { remoteWorkspaceRefKind: exported?.remoteWorkspaceRefKind, scopeKind: exported?.scopeKind, artifacts: exported?.artifacts ?? [], + constraintSatisfied: exported?.constraintSatisfied, + missingRequiredExtensions: exported?.missingRequiredExtensions, warnings: exported?.warnings ?? [], artifactCount: exported?.artifacts.length ?? 0, };