fix(taskState): report artifact fallback as unknown evidence
This commit is contained in:
parent
35379f2fb0
commit
fc6a02ac1a
15
dist/src/taskState.js
vendored
15
dist/src/taskState.js
vendored
@ -165,9 +165,10 @@ export async function getXWorkmateTaskSnapshot(input) {
|
|||||||
: undefined;
|
: undefined;
|
||||||
if (exported?.artifacts.length) {
|
if (exported?.artifacts.length) {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: false,
|
||||||
status: "completed",
|
status: "unknown",
|
||||||
taskStatus: "succeeded",
|
taskStatus: "unknown",
|
||||||
|
evidence: "artifacts_present",
|
||||||
mode: "gateway-chat",
|
mode: "gateway-chat",
|
||||||
mapping,
|
mapping,
|
||||||
appThreadKey: mapping?.appThreadKey ?? appThreadKey,
|
appThreadKey: mapping?.appThreadKey ?? appThreadKey,
|
||||||
@ -177,7 +178,7 @@ export async function getXWorkmateTaskSnapshot(input) {
|
|||||||
task: {
|
task: {
|
||||||
taskId: taskId || runId,
|
taskId: taskId || runId,
|
||||||
runId,
|
runId,
|
||||||
status: "succeeded",
|
status: "unknown",
|
||||||
source: "artifact_fallback",
|
source: "artifact_fallback",
|
||||||
},
|
},
|
||||||
expectedArtifactDirs: mapping?.expectedArtifactDirs ?? [],
|
expectedArtifactDirs: mapping?.expectedArtifactDirs ?? [],
|
||||||
@ -186,9 +187,11 @@ export async function getXWorkmateTaskSnapshot(input) {
|
|||||||
remoteWorkspaceRefKind: exported.remoteWorkspaceRefKind,
|
remoteWorkspaceRefKind: exported.remoteWorkspaceRefKind,
|
||||||
scopeKind: exported.scopeKind,
|
scopeKind: exported.scopeKind,
|
||||||
artifacts: exported.artifacts,
|
artifacts: exported.artifacts,
|
||||||
|
constraintSatisfied: exported.constraintSatisfied,
|
||||||
|
missingRequiredExtensions: exported.missingRequiredExtensions,
|
||||||
warnings: [
|
warnings: [
|
||||||
...exported.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,
|
artifactCount: exported.artifacts.length,
|
||||||
};
|
};
|
||||||
@ -217,6 +220,8 @@ export async function getXWorkmateTaskSnapshot(input) {
|
|||||||
remoteWorkspaceRefKind: exported?.remoteWorkspaceRefKind,
|
remoteWorkspaceRefKind: exported?.remoteWorkspaceRefKind,
|
||||||
scopeKind: exported?.scopeKind,
|
scopeKind: exported?.scopeKind,
|
||||||
artifacts: exported?.artifacts ?? [],
|
artifacts: exported?.artifacts ?? [],
|
||||||
|
constraintSatisfied: exported?.constraintSatisfied,
|
||||||
|
missingRequiredExtensions: exported?.missingRequiredExtensions,
|
||||||
warnings: exported?.warnings ?? [],
|
warnings: exported?.warnings ?? [],
|
||||||
artifactCount: exported?.artifacts.length ?? 0,
|
artifactCount: exported?.artifacts.length ?? 0,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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 workspaceDir = await createWorkspaceFixture();
|
||||||
const appThreadKey = "draft:sample-task";
|
const appThreadKey = "draft:sample-task";
|
||||||
const openclawSessionKey = "agent:main:draft:sample-task";
|
const openclawSessionKey = "agent:main:draft:sample-task";
|
||||||
const runId = "turn-sample";
|
const runId = "turn-sample";
|
||||||
const artifactDir = path.join(workspaceDir, "tasks", "agent_main_draft_sample-task", runId);
|
const artifactDir = path.join(workspaceDir, "tasks", "agent_main_draft_sample-task", runId);
|
||||||
await fs.mkdir(artifactDir, { recursive: true });
|
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 });
|
const { api } = createApiFixture({}, { workspaceDir });
|
||||||
await recordXWorkmateSessionMapping({
|
await recordXWorkmateSessionMapping({
|
||||||
@ -196,21 +196,25 @@ describe("xworkmate task state mapping", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
success: true,
|
success: false,
|
||||||
status: "completed",
|
status: "unknown",
|
||||||
taskStatus: "succeeded",
|
taskStatus: "unknown",
|
||||||
|
evidence: "artifacts_present",
|
||||||
openclawSessionKey,
|
openclawSessionKey,
|
||||||
runId,
|
runId,
|
||||||
task: {
|
task: {
|
||||||
source: "artifact_fallback",
|
source: "artifact_fallback",
|
||||||
|
status: "unknown",
|
||||||
},
|
},
|
||||||
artifacts: [
|
artifacts: [
|
||||||
{
|
{
|
||||||
relativePath: "report.md",
|
relativePath: "series.config.json",
|
||||||
contentType: "text/markdown",
|
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 () => {
|
it("returns no_native_task_record when neither native task record nor task artifacts exist", async () => {
|
||||||
|
|||||||
@ -260,9 +260,10 @@ export async function getXWorkmateTaskSnapshot(input: {
|
|||||||
: undefined;
|
: undefined;
|
||||||
if (exported?.artifacts.length) {
|
if (exported?.artifacts.length) {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: false,
|
||||||
status: "completed",
|
status: "unknown",
|
||||||
taskStatus: "succeeded",
|
taskStatus: "unknown",
|
||||||
|
evidence: "artifacts_present",
|
||||||
mode: "gateway-chat",
|
mode: "gateway-chat",
|
||||||
mapping,
|
mapping,
|
||||||
appThreadKey: mapping?.appThreadKey ?? appThreadKey,
|
appThreadKey: mapping?.appThreadKey ?? appThreadKey,
|
||||||
@ -272,7 +273,7 @@ export async function getXWorkmateTaskSnapshot(input: {
|
|||||||
task: {
|
task: {
|
||||||
taskId: taskId || runId,
|
taskId: taskId || runId,
|
||||||
runId,
|
runId,
|
||||||
status: "succeeded",
|
status: "unknown",
|
||||||
source: "artifact_fallback",
|
source: "artifact_fallback",
|
||||||
},
|
},
|
||||||
expectedArtifactDirs: mapping?.expectedArtifactDirs ?? [],
|
expectedArtifactDirs: mapping?.expectedArtifactDirs ?? [],
|
||||||
@ -281,9 +282,11 @@ export async function getXWorkmateTaskSnapshot(input: {
|
|||||||
remoteWorkspaceRefKind: exported.remoteWorkspaceRefKind,
|
remoteWorkspaceRefKind: exported.remoteWorkspaceRefKind,
|
||||||
scopeKind: exported.scopeKind,
|
scopeKind: exported.scopeKind,
|
||||||
artifacts: exported.artifacts,
|
artifacts: exported.artifacts,
|
||||||
|
constraintSatisfied: exported.constraintSatisfied,
|
||||||
|
missingRequiredExtensions: exported.missingRequiredExtensions,
|
||||||
warnings: [
|
warnings: [
|
||||||
...exported.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,
|
artifactCount: exported.artifacts.length,
|
||||||
};
|
};
|
||||||
@ -320,6 +323,8 @@ export async function getXWorkmateTaskSnapshot(input: {
|
|||||||
remoteWorkspaceRefKind: exported?.remoteWorkspaceRefKind,
|
remoteWorkspaceRefKind: exported?.remoteWorkspaceRefKind,
|
||||||
scopeKind: exported?.scopeKind,
|
scopeKind: exported?.scopeKind,
|
||||||
artifacts: exported?.artifacts ?? [],
|
artifacts: exported?.artifacts ?? [],
|
||||||
|
constraintSatisfied: exported?.constraintSatisfied,
|
||||||
|
missingRequiredExtensions: exported?.missingRequiredExtensions,
|
||||||
warnings: exported?.warnings ?? [],
|
warnings: exported?.warnings ?? [],
|
||||||
artifactCount: exported?.artifacts.length ?? 0,
|
artifactCount: exported?.artifacts.length ?? 0,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user