refactor(cron): rename scheduler feature to cron

Rename the recurring-jobs feature scheduler->cron to disambiguate from the
legacy ScheduledRun system (/api/scheduled), which is left untouched:

- ScheduledJob->CronJob, SchedulerService->CronService
- /api/scheduler/jobs -> /api/cron/jobs; SSE scheduler:* -> cron:*
- state keys cronJobs/cronJobRuns
- files moved to src/cron/, cron-routes.ts, cron-port.ts, types/cron.ts
- frontend cron-ui.js, #cronModal, menu "Cron"
- docs moved to docs/cron-discovery.md + docs/cron-build-brief.md, README guides
- new tests: cron-service.test.ts, cron-time.test.ts

Green: tsc, lint, frontend-syntax, format, 30 cron + 9 legacy scheduled-runs tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PmvZR12aX2v8K7YhqxPUAU
This commit is contained in:
Kris
2026-06-29 11:35:56 +05:30
co-authored by Claude Opus 4.8
parent 2d2f4e592b
commit 9feaa0d6e5
27 changed files with 1383 additions and 370 deletions
+3 -3
View File
@@ -23,7 +23,7 @@ import type { SessionState } from './session.js';
import type { TaskState } from './task.js';
import type { RalphLoopState } from './ralph.js';
import type { RespawnConfig } from './respawn.js';
import type { ScheduledJob, ScheduledJobRun } from './scheduler.js';
import type { CronJob, CronJobRun } from './cron.js';
// ========== Global Stats Types ==========
@@ -113,9 +113,9 @@ export interface AppState {
/** Orchestrator Loop state (phased plan execution) */
orchestrator?: import('./orchestrator.js').OrchestratorPersistState;
/** Cron-style scheduled jobs, keyed by job ID. */
scheduledJobs?: Record<string, ScheduledJob>;
cronJobs?: Record<string, CronJob>;
/** Scheduled job run history, keyed by run ID. */
scheduledJobRuns?: Record<string, ScheduledJobRun>;
cronJobRuns?: Record<string, CronJobRun>;
}
// ========== Default Configuration ==========
+11 -11
View File
@@ -1,11 +1,11 @@
/**
* @fileoverview Scheduled Jobs (cron-style scheduler) type definitions.
* @fileoverview Cron Jobs type definitions.
*
* NOTE: This is intentionally distinct from the existing `ScheduledRun` concept
* (see src/web/ports/infra-port.ts), which is a run-now, duration-bounded
* autonomous loop. A `ScheduledJob` is a SAVED, NAMED job with a recurring
* autonomous loop. A `CronJob` is a SAVED, NAMED job with a recurring
* schedule (once/interval/daily/weekly), enable/disable, next-run calculation,
* and a history of `ScheduledJobRun` records. The two do not interact.
* and a history of `CronJobRun` records. The two do not interact.
*
* Persisted to `~/.codeman/state.json` via StateStore (see AppState).
*/
@@ -22,7 +22,7 @@ export type PromptMode = 'inline_text' | 'prompt_file_path';
export type InputMode = 'paste' | 'typed';
/** Lifecycle status of a single job execution. */
export type ScheduledJobRunStatus = 'created' | 'session_started' | 'prompt_sent' | 'failed';
export type CronJobRunStatus = 'created' | 'session_started' | 'prompt_sent' | 'failed';
/** What triggered a run. */
export type TriggerType = 'scheduled' | 'manual_run_now';
@@ -31,9 +31,9 @@ export type TriggerType = 'scheduled' | 'manual_run_now';
export type ConcurrencyPolicy = 'warn_only' | 'skip_if_same_agent_running';
/**
* A saved, named scheduled job.
* A saved, named cron job.
*/
export interface ScheduledJob {
export interface CronJob {
id: string;
name: string;
/** Reuses Codeman's existing session modes; 'shell' covers Terminal/custom. */
@@ -69,7 +69,7 @@ export interface ScheduledJob {
updatedAt: number;
lastRunAt: number | null;
nextRunAt: number | null;
lastStatus: ScheduledJobRunStatus | null;
lastStatus: CronJobRunStatus | null;
/** Duplicate-launch guard: identifies the most recent due-time consumed. */
lastDueKey: string | null;
/** True once a 'once' job has fired (it is also disabled). */
@@ -77,16 +77,16 @@ export interface ScheduledJob {
}
/**
* A single execution of a scheduled job (history record).
* A single execution of a cron job (history record).
*/
export interface ScheduledJobRun {
export interface CronJobRun {
id: string;
scheduledJobId: string;
cronJobId: string;
sessionId: string | null;
sessionName: string | null;
startedAt: number;
finishedAt: number | null;
status: ScheduledJobRunStatus;
status: CronJobRunStatus;
errorMessage?: string;
triggerType: TriggerType;
/** Best-effort deep link to the created session in the web UI. */