Skip to content

feat(schedule): add server task declarations and local execution - #144

Closed
xusd320 wants to merge 2 commits into
mainfrom
xusd320/server-schedules
Closed

xusd320 wants to merge 2 commits into
mainfrom
xusd320/server-schedules

Conversation

@xusd320

@xusd320 xusd320 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add defineSchedule({ cron, id?, disable? }, handler) for server tasks declared under the fixed src/schedules/ directory, with free filenames and nested directories and no central registry.
  • Add explicit local execution with ev schedule run <id>; ordinary development does not start periodic jobs.

Changes

  • Discover and validate named declarations only within src/schedules/, enforce server boundaries, and carry task metadata through the core graph and deployment manifest. Declarations outside this directory are not registered; handlers can import ordinary business functions from other directories.
  • Generate an awaitable runSchedule(taskId) bundle entry; support task-only applications and mixed HTTP/task builds.
  • Compile local task runs into disposable output without invoking deployment hooks or replacing build artifacts; expose declarations in ev inspect.
  • Support Utoopack server-only builds with a private generated client entry and add equivalent English/Chinese docs.

Validation

  • npm test -- --concurrency=1: 2,139 tests passed (17 tasks), including 894 @evjs/ev tests. Package tasks were serialized after a parallel run hit an existing config-helper test's 5-second timeout.
  • npm run check-types, root test type checking, npm run lint, and git diff --check passed.
  • npm --workspace evjs-docs run build: English and Chinese builds passed.
  • Schedule regressions cover nested directories, ignored out-of-directory declarations, first directory creation, stable IDs, client-boundary errors, and task-only graphs.

Risk / rollout

  • Adds a schedule manifest/bundle contract; deployment adapters must consume it and provide platform scheduling.
  • No in-process timer, retry policy, or distributed execution guarantee is introduced. Platform trigger acceptance remains separate from local build/execution validation.

Reviewer notes

  • Focus on the fixed directory boundary, discovery after directory creation, client/server boundaries, stable task IDs, task-only output ownership, and cleanup of temporary local builds.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T12:33:22.415467Z 46c4b3d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46c4b3dd8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +337 to +340
...(input.graph.serverSchedules?.length
? {
schedules: input.graph.serverSchedules.map((task) => ({ ...task })),
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Mark schedules unsupported for static deployments

When an otherwise static-compatible build contains a schedule, this adds it to output.server.schedules, but analyzeStaticDeploymentCompatibility() still checks only functions, routes, and server-rendered pages. Consequently createStaticDeploymentFiles() reports compatibility.complete: true even though a static host cannot execute the schedule, so deployments can silently omit every trigger. Add schedules to StaticDeploymentUnsupportedCapability and the compatibility check.

Useful? React with 👍 / 👎.

} {
const schedules: ServerScheduleNode[] = [];
const diagnostics: Diagnostic[] = [];
if (!source.includes("defineSchedule")) return { schedules, diagnostics };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Filter for schedule imports before parsing source files

Because discovery visits every source file, this substring check makes any file that merely mentions defineSchedule a parse target. An unreferenced work-in-progress file such as one containing a // defineSchedule example comment and incomplete syntax now produces a schedule parse diagnostic and fails every build, even though it neither imports the declaration API nor participates in the application graph. Restrict the prefilter to plausible imports from the supported schedule modules before treating parse failures as schedule diagnostics.

Useful? React with 👍 / 👎.

@xusd320 xusd320 closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant