Skip to content

Commit f2b3d15

Browse files
ruel225claudevincentkoc
authored
fix(workboard): diagnose archived cards still in an active status (#116359) (#117290)
* fix(workboard): diagnose archived cards still in an active status An archived card with an active status (ready/running/blocked/etc.) was silently excluded from dispatch with no signal on any surface — workboard show rendered it normally, dispatch returned count:0 with empty startFailures, and computeCardDiagnostics returned [] for archived cards. Operators could only find it by reading the database directly. Add an archived_but_active diagnostic kind to WORKBOARD_DIAGNOSTIC_KINDS and an unarchive action. In computeCardDiagnostics, when a card has archivedAt set but status is not done, emit the warning so workboard show and store.diagnostics report it. Done+archived cards stay silent (no diagnostic) as before. The diagnostic is transient — refreshDiagnostics still skips archived cards, so their stored metadata is not rewritten. Fixes #116359 Co-Authored-By: Claude <[email protected]> * fix(workboard): expose archived active cards * ci: re-trigger after sqlite flip-proof e2e flake Unrelated to workboard diagnostic changes; sqlite session/transcript flip-proof e2e failed with array mismatch on an untouched path. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: ruel225 <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
1 parent 0181ba6 commit f2b3d15

8 files changed

Lines changed: 104 additions & 1 deletion

File tree

‎docs/plugins/workboard.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ Diagnostics are computed from local card metadata. Built-in checks flag:
375375
| `repeated_failures` | Card's tracked failure count reaches 2 or more. |
376376
| `missing_proof` | `done` card with no proof, artifacts, or attachments. |
377377
| `orphaned_session` | `running` card with a `sessionKey` but no `execution` metadata. |
378+
| `archived_but_active` | Archived card remains in any non-`done` lifecycle status. |
378379

379380
## Permissions
380381

‎extensions/workboard/src/cli.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ describe("registerWorkboardCli", () => {
140140
expect(defaultOutput).not.toContain("Archived card");
141141
expect(includeOutput).toContain("Active card");
142142
expect(includeOutput).toContain("Archived card");
143+
expect(includeOutput).toContain("(archived)");
144+
});
145+
146+
it("marks archived cards in show output", async () => {
147+
const store = new WorkboardStore(createMemoryStore());
148+
const archived = await store.create({ title: "Archived card", status: "ready" });
149+
await store.archive(archived.id, true);
150+
const program = createProgram(store);
151+
152+
const output = await captureStdout(async () => {
153+
await program.parseAsync(["workboard", "show", archived.id], { from: "user" });
154+
});
155+
156+
expect(output).toContain("Archived card (archived)");
143157
});
144158

145159
it("preserves archived cards in JSON list output by default", async () => {

‎extensions/workboard/src/cli.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ function isWorkboardStatus(value: string): value is WorkboardStatus {
6969
function formatCardLine(card: WorkboardCard): string {
7070
const boardId = card.metadata?.automation?.boardId ?? "default";
7171
const agent = card.agentId ? ` ${card.agentId}` : "";
72-
return `${card.id.slice(0, 8)} ${card.status.padEnd(8)} ${card.priority.padEnd(6)} ${boardId}${agent} ${card.title}`;
72+
const archived = card.metadata?.archivedAt ? " (archived)" : "";
73+
return `${card.id.slice(0, 8)} ${card.status.padEnd(8)} ${card.priority.padEnd(6)} ${boardId}${agent} ${card.title}${archived}`;
7374
}
7475

7576
function redactDispatchResult(result: WorkboardDispatchResult): WorkboardDispatchResult {

‎extensions/workboard/src/command.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,19 @@ describe("handleWorkboardCommand", () => {
291291
await expect(store.get(card.id)).resolves.toMatchObject({ status: "ready" });
292292
});
293293

294+
it("shows when an archived card is excluded from dispatch", async () => {
295+
const store = new WorkboardStore(createMemoryStore());
296+
const api = createApi();
297+
const card = await store.create({ title: "Archived slash card", status: "ready" });
298+
await store.archive(card.id, true);
299+
300+
await expect(runWorkboardCommand({ api, store, args: `show ${card.id}` })).resolves.toEqual(
301+
expect.objectContaining({
302+
text: expect.stringContaining("archived: yes (excluded from dispatch)"),
303+
}),
304+
);
305+
});
306+
294307
it("moves claimed cards for operators on slash-command surfaces", async () => {
295308
const store = new WorkboardStore(createMemoryStore());
296309
const api = createApi();

‎extensions/workboard/src/command.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ function formatCardDetails(card: WorkboardCard): string {
5858
if (card.runId) {
5959
lines.push(`run: ${card.runId}`);
6060
}
61+
if (card.metadata?.archivedAt) {
62+
lines.push("archived: yes (excluded from dispatch)");
63+
}
6164
if (card.notes) {
6265
lines.push("", card.notes);
6366
}

‎extensions/workboard/src/store-card-helpers.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,22 @@ export function mergeDiagnostics(
395395

396396
export function computeCardDiagnostics(card: WorkboardCard, now: number): WorkboardDiagnostic[] {
397397
if (card.metadata?.archivedAt) {
398+
// Archived cards intentionally skip automation. Keep nonterminal cards
399+
// visible as a transient diagnostic without rewriting archived metadata.
400+
if (card.status !== "done") {
401+
return [
402+
diagnostic(
403+
{
404+
kind: "archived_but_active",
405+
severity: "warning",
406+
title: "Archived card is still in an active status",
407+
detail: `Card status is "${card.status}" but it is archived, so it is excluded from dispatch without any start failure or error. Unarchive it or move it to "done" to stop the silent skip.`,
408+
actions: [],
409+
},
410+
now,
411+
),
412+
];
413+
}
398414
return [];
399415
}
400416
const diagnostics: WorkboardDiagnostic[] = [];

‎extensions/workboard/src/store.test.ts‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import fs from "node:fs";
33
import os from "node:os";
44
import path from "node:path";
55
import { DatabaseSync } from "node:sqlite";
6+
import { WORKBOARD_STATUSES } from "@openclaw/workboard-contract";
67
import { MAX_DATE_TIMESTAMP_MS } from "openclaw/plugin-sdk/number-runtime";
78
import { describe, expect, it, vi } from "vitest";
89
import type {
@@ -2618,6 +2619,59 @@ describe("WorkboardStore", () => {
26182619
});
26192620
});
26202621

2622+
it.each(WORKBOARD_STATUSES)(
2623+
"reports archived %s cards according to terminal state",
2624+
async (status) => {
2625+
const store = new WorkboardStore(createMemoryStore());
2626+
const card = await store.create({ title: `Archived ${status}`, status });
2627+
2628+
await store.archive(card.id, true);
2629+
2630+
const result = await store.diagnostics(Date.now());
2631+
if (status === "done") {
2632+
expect(result).toEqual({ diagnostics: [], count: 0 });
2633+
return;
2634+
}
2635+
expect(result).toMatchObject({
2636+
diagnostics: [
2637+
expect.objectContaining({
2638+
card: expect.objectContaining({ id: card.id }),
2639+
diagnostics: [
2640+
expect.objectContaining({
2641+
kind: "archived_but_active",
2642+
severity: "warning",
2643+
actions: [],
2644+
}),
2645+
],
2646+
}),
2647+
],
2648+
count: 1,
2649+
});
2650+
},
2651+
);
2652+
2653+
it("keeps archived-card diagnostics transient across lifecycle changes", async () => {
2654+
const store = new WorkboardStore(createMemoryStore());
2655+
const card = await store.create({ title: "Archived but ready", status: "ready" });
2656+
const now = Date.now();
2657+
2658+
await store.archive(card.id, true);
2659+
2660+
await expect(store.refreshDiagnostics(now)).resolves.toEqual({ diagnostics: [], count: 0 });
2661+
await expect(store.get(card.id)).resolves.not.toHaveProperty("metadata.diagnostics");
2662+
await expect(store.diagnostics(now)).resolves.toMatchObject({
2663+
diagnostics: [expect.objectContaining({ card: expect.objectContaining({ id: card.id }) })],
2664+
count: 1,
2665+
});
2666+
2667+
await store.archive(card.id, false);
2668+
await expect(store.diagnostics(now + 1)).resolves.toEqual({ diagnostics: [], count: 0 });
2669+
2670+
await store.archive(card.id, true);
2671+
await store.move(card.id, "done", undefined);
2672+
await expect(store.diagnostics(now + 2)).resolves.toEqual({ diagnostics: [], count: 0 });
2673+
});
2674+
26212675
it("does not drop concurrent updates while refreshing diagnostics", async () => {
26222676
let proofPromise: Promise<unknown> | undefined;
26232677
let triggered = false;

‎packages/workboard-contract/src/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const WORKBOARD_DIAGNOSTIC_KINDS = [
7171
"repeated_failures",
7272
"missing_proof",
7373
"orphaned_session",
74+
"archived_but_active",
7475
] as const;
7576
export const WORKBOARD_DIAGNOSTIC_SEVERITIES = ["warning", "error", "critical"] as const;
7677
export const WORKBOARD_NOTIFICATION_KINDS = ["completed", "failed", "stale"] as const;

0 commit comments

Comments
 (0)