docs: document cron normalization and run logs · openclaw/openclaw@875c9fd
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Mutates and persists isolated cron session state around one run. */ |
1 | 2 | import fs from "node:fs"; |
2 | 3 | import type { LiveSessionModelSelection } from "../../agents/live-model-switch.js"; |
3 | 4 | import type { SessionEntry } from "../../config/sessions.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Repairs legacy cron job identity fields into the canonical id shape. */ |
1 | 2 | import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce"; |
2 | 3 | |
3 | 4 | /** Normalizes mutable cron job rows from old `jobId` storage into the canonical `id` field. */ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Normalizes cron create/patch payloads before validation and persistence. */ |
1 | 2 | import { timestampMsToIsoString } from "@openclaw/normalization-core/number-coercion"; |
2 | 3 | import { |
3 | 4 | normalizeLowercaseStringOrEmpty, |
@@ -238,6 +239,7 @@ function coerceDelivery(delivery: UnknownRecord) {
|
238 | 239 | delete next.accountId; |
239 | 240 | } |
240 | 241 | if ("failureDestination" in next) { |
| 242 | +// Null is an explicit clear signal in patches; invalid objects are dropped. |
241 | 243 | if (next.failureDestination === null) { |
242 | 244 | next.failureDestination = null; |
243 | 245 | } else if (isRecord(next.failureDestination)) { |
@@ -247,6 +249,8 @@ function coerceDelivery(delivery: UnknownRecord) {
|
247 | 249 | } |
248 | 250 | } |
249 | 251 | if ("completionDestination" in next) { |
| 252 | +// Completion destinations are currently webhook-only, so other shapes are |
| 253 | +// discarded before they can persist as ambiguous config. |
250 | 254 | if (next.completionDestination === null) { |
251 | 255 | next.completionDestination = null; |
252 | 256 | } else { |
@@ -449,6 +453,8 @@ export function normalizeCronJobInput(
|
449 | 453 | } |
450 | 454 | |
451 | 455 | if (options.applyDefaults) { |
| 456 | +// Defaults apply only on create; patch normalization must preserve omitted |
| 457 | +// fields so partial updates do not rewrite unrelated cron settings. |
452 | 458 | if (!next.wakeMode) { |
453 | 459 | next.wakeMode = "now"; |
454 | 460 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Parses cron schedule timestamps from user-facing absolute time strings. */ |
1 | 2 | import { parseStrictPositiveInteger } from "../infra/parse-finite-number.js"; |
2 | 3 | |
3 | 4 | const ISO_TZ_RE = /(Z|[+-]\d{2}:?\d{2})$/i; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Validates persisted cron job records before loading them from disk/state. */ |
1 | 2 | import { parseAbsoluteTimeMs } from "./parse.js"; |
2 | 3 | |
3 | 4 | /** Structural rejection code for persisted cron jobs that cannot be loaded safely. */ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Classifies cron run failures for retry policy decisions. */ |
1 | 2 | import type { CronRetryOn } from "../config/types.cron.js"; |
2 | 3 | |
3 | 4 | /** Cron retry classifier output consumed by scheduler retry policy. */ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Builds bounded, redacted diagnostics for cron run logs and UI surfaces. */ |
1 | 2 | import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce"; |
2 | 3 | import { getReplyPayloadMetadata } from "../auto-reply/reply-payload.js"; |
3 | 4 | import { redactSensitiveText } from "../logging/redact.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Legacy JSONL run-log parser used during migrations/imports. */ |
1 | 2 | import type { CronRunLogEntry } from "./run-log-types.js"; |
2 | 3 | import { parseCronRunLogEntryObject } from "./run-log/entry-codec.js"; |
3 | 4 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Shared cron run-log entry shape for SQLite and legacy JSONL stores. */ |
1 | 2 | import type { FailoverReason } from "../agents/embedded-agent-helpers/types.js"; |
2 | 3 | import type { |
3 | 4 | CronDeliveryStatus, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +/** Public cron run-log API with serialized writes and paged reads. */ |
1 | 2 | import { |
2 | 3 | normalizeLowercaseStringOrEmpty, |
3 | 4 | normalizeOptionalString, |
@@ -306,6 +307,8 @@ export async function readCronRunLogEntriesPage(
|
306 | 307 | const offset = Math.max(0, Math.floor(opts.offset ?? 0)); |
307 | 308 | |
308 | 309 | if (!query) { |
| 310 | +// Without a text query SQLite can page directly; query mode filters in JS |
| 311 | +// because diagnostics and derived job names are not all indexed columns. |
309 | 312 | const total = countCronRunLogRows({ |
310 | 313 | db, |
311 | 314 | storeKey, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。