Skip to content

Commit e3dd620

Browse files
author
Pincer
committed
fix: address P2 review findings — schema registration, independent timer, no post-flush reschedule
1 parent ad1a175 commit e3dd620

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/config/zod-schema.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,12 @@ export const OpenClawSchema = z
11241124
)
11251125
.optional(),
11261126
proxy: ProxyConfigSchema,
1127+
trajectory: z
1128+
.object({
1129+
flushTimeoutMs: z.number().int().positive().optional(),
1130+
})
1131+
.strict()
1132+
.optional(),
11271133
})
11281134
.strict()
11291135
.superRefine((cfg, ctx) => {

src/trajectory/runtime.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ type TrajectoryRuntimeInit = {
4747
* 2. env.OPENCLAW_TRAJECTORY_FLUSH_TIMEOUT_MS
4848
* 3. undefined (no periodic flush)
4949
*/
50-
function resolveFlushTimeoutMs(
51-
cfg?: OpenClawConfig,
52-
env?: NodeJS.ProcessEnv,
53-
): number | undefined {
50+
function resolveFlushTimeoutMs(cfg?: OpenClawConfig, env?: NodeJS.ProcessEnv): number | undefined {
5451
const cfgValue = cfg?.trajectory?.flushTimeoutMs;
5552
if (typeof cfgValue === "number" && cfgValue > 0) {
5653
return cfgValue;
@@ -390,11 +387,8 @@ export function createTrajectoryRuntimeRecorder(
390387
}
391388
writeBoundedLine(line, { reserveSentinel: true });
392389

393-
// Reschedule periodic flush on new events.
394-
if (flushTimeoutMs !== undefined) {
395-
cancelFlushTimer();
396-
scheduleFlush();
397-
}
390+
// Do NOT reschedule on each event — timer runs independently once started.
391+
// scheduleFlush() is called once at initialization.
398392
},
399393
flush: async () => {
400394
// Cancel any pending periodic flush.
@@ -417,10 +411,7 @@ export function createTrajectoryRuntimeRecorder(
417411
if (!params.writer) {
418412
writers.delete(filePath);
419413
}
420-
421-
// Reschedule periodic flush if enabled.
422-
lastFlushTime = Date.now();
423-
scheduleFlush();
414+
// Timer already cancelled above; do not reschedule after final flush.
424415
},
425416
};
426417
}

0 commit comments

Comments
 (0)