惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
月光博客
月光博客
博客园 - Franky
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
有赞技术团队
有赞技术团队
V
V2EX
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
腾讯CDC
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
Martin Fowler
Martin Fowler
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
WordPress大学
WordPress大学
C
Check Point Blog
Microsoft Azure Blog
Microsoft Azure Blog
Microsoft Security Blog
Microsoft Security Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
feat(tasks): explain stale-running maintenance decisions ...
efpiva · 2026-05-21 · via Recent Commits to openclaw:main

@@ -64,6 +64,7 @@ import type { TaskRecord, TaskRegistrySummary, TaskStatus } from "./task-registr

6464

const log = createSubsystemLogger("tasks/task-registry-maintenance");

6565

const TASK_RECONCILE_GRACE_MS = 5 * 60_000;

6666

const CHILDLESS_CODEX_NATIVE_RECONCILE_GRACE_MS = 30 * 60_000;

67+

const TASK_STALE_RUNNING_MS = 30 * 60_000;

6768

const TASK_RETENTION_MS = 7 * 24 * 60 * 60_000;

6869

const TASK_SWEEP_INTERVAL_MS = 60_000;

6970

@@ -162,6 +163,28 @@ export type TaskRegistryMaintenanceSummary = {

162163

pruned: number;

163164

};

164165166+

export type TaskRegistryMaintenanceTaskDiagnostic = {

167+

taskId: string;

168+

runtime: TaskRecord["runtime"];

169+

status: TaskRecord["status"];

170+

decision: "retained" | "would_reconcile";

171+

reason:

172+

| "active_cli_run"

173+

| "backing_session_missing"

174+

| "backing_session_present"

175+

| "cron_runtime_not_authoritative"

176+

| "lost_grace_pending"

177+

| "subagent_recovery_wedged";

178+

detail?: string;

179+

ageMs: number;

180+

childSessionKey?: string;

181+

runId?: string;

182+

};

183+184+

export type TaskRegistryMaintenanceDiagnostics = {

185+

staleRunningTasks: TaskRegistryMaintenanceTaskDiagnostic[];

186+

};

187+165188

type CronExecutionId = {

166189

jobId: string;

167190

startedAt: number;

@@ -562,6 +585,10 @@ function resolveCleanupAfter(task: TaskRecord): number {

562585

return terminalAt + TASK_RETENTION_MS;

563586

}

564587588+

function taskReferenceAt(task: TaskRecord): number {

589+

return task.lastEventAt ?? task.startedAt ?? task.createdAt;

590+

}

591+565592

function getNormalizedTaskChildSessionKey(task: TaskRecord): string | undefined {

566593

return normalizeOptionalString(task.childSessionKey);

567594

}

@@ -952,6 +979,72 @@ export function previewTaskRegistryMaintenance(): TaskRegistryMaintenanceSummary

952979

return { reconciled, recovered, cleanupStamped, pruned };

953980

}

954981982+

function explainActiveTaskRetention(params: {

983+

task: TaskRecord;

984+

now: number;

985+

context: BackingSessionLookupContext;

986+

}): Pick<TaskRegistryMaintenanceTaskDiagnostic, "decision" | "reason" | "detail"> {

987+

if (!hasLostGraceExpired(params.task, params.now)) {

988+

return { decision: "retained", reason: "lost_grace_pending" };

989+

}

990+

if (params.task.runtime === "subagent") {

991+

const entry = findTaskSessionEntry(params.task, params.context);

992+

if (entry && isSubagentRecoveryWedgedEntry(entry)) {

993+

return {

994+

decision: "would_reconcile",

995+

reason: "subagent_recovery_wedged",

996+

detail: formatSubagentRecoveryWedgedReason(entry),

997+

};

998+

}

999+

}

1000+

if (!hasBackingSession(params.task, params.context)) {

1001+

return { decision: "would_reconcile", reason: "backing_session_missing" };

1002+

}

1003+

if (

1004+

params.task.runtime === "cron" &&

1005+

!taskRegistryMaintenanceRuntime.isCronRuntimeAuthoritative()

1006+

) {

1007+

return { decision: "retained", reason: "cron_runtime_not_authoritative" };

1008+

}

1009+

if (params.task.runtime === "cli" && hasActiveCliRun(params.task)) {

1010+

return { decision: "retained", reason: "active_cli_run" };

1011+

}

1012+

return { decision: "retained", reason: "backing_session_present" };

1013+

}

1014+1015+

export function getTaskRegistryMaintenanceDiagnostics(): TaskRegistryMaintenanceDiagnostics {

1016+

taskRegistryMaintenanceRuntime.ensureTaskRegistryReady();

1017+

const now = Date.now();

1018+

const cronRecoveryContext = createCronRecoveryContext();

1019+

const backingSessionContext = createBackingSessionLookupContext();

1020+

const staleRunningTasks: TaskRegistryMaintenanceTaskDiagnostic[] = [];

1021+

for (const task of taskRegistryMaintenanceRuntime.listTaskRecords()) {

1022+

if (task.status !== "running") {

1023+

continue;

1024+

}

1025+

const ageMs = Math.max(0, now - taskReferenceAt(task));

1026+

if (ageMs < TASK_STALE_RUNNING_MS) {

1027+

continue;

1028+

}

1029+

if (resolveDurableCronTaskRecovery(task, cronRecoveryContext)) {

1030+

continue;

1031+

}

1032+

const decision = explainActiveTaskRetention({ task, now, context: backingSessionContext });

1033+

staleRunningTasks.push({

1034+

taskId: task.taskId,

1035+

runtime: task.runtime,

1036+

status: task.status,

1037+

decision: decision.decision,

1038+

reason: decision.reason,

1039+

ageMs,

1040+

...(decision.detail ? { detail: decision.detail } : {}),

1041+

...(task.childSessionKey ? { childSessionKey: task.childSessionKey } : {}),

1042+

...(task.runId ? { runId: task.runId } : {}),

1043+

});

1044+

}

1045+

return { staleRunningTasks };

1046+

}

1047+9551048

/**

9561049

* Yield control back to the event loop so that pending I/O callbacks,

9571050

* timers, and incoming requests can be processed between batches of