Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

routines: support a first-run timestamp anchor for interval routines

オープン
#584 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php, wordpress
領域
backend

調査の方向性

Start in the WP_Agent_Routine class and the WP_Agent_Routine_Action_Scheduler_Bridge::register() method, which currently schedules the first action at time() plus stagger_offset(). Add an optional first_run arg, and check that stagger_offset(), recurrence_matches() and to_array() behave as the issue describes. Done means register() uses a future first_run only when it mints a new chain, stagger_offset() returns 0 when first_run is set, recurrence_matches() still compares only interval and expression, and the existing tests pass with new coverage for these cases.

索引モデルが issue の本文から書いたものです。

説明

Problem

WP_Agent_Routine has no way to declare a first-run timestamp for an interval routine. WP_Agent_Routine_Action_Scheduler_Bridge::register() always schedules the first action at time() + $routine->stagger_offset(). A consumer that needs a routine anchored to a wall-clock time (for example "weekly, first run next Thursday 15:00 UTC") can't express it with supported args. The only workaround is a cron expression.

Downstream impact: Extra-Chill/data-machine#3618. System schedules declare first_run_callback / first_run_arg (e.g. 'tomorrow midnight', 'next thursday 15:00 UTC'). Routines were silently ignoring them, so a weekly digest was about to fire 37 minutes after it was enabled instead of at its Thursday anchor.

Current consumer workaround (data-machine)

After register(), data-machine compares current_generation() from before and after the call. If a fresh chain was minted, it stores an anchored as_schedule_recurring_action() with the bridge's SCHEDULED_HOOK/GROUP, cancels the bridge's provisional recurring action through cancel(), and refreshes the cache through pending_by_routine(). This works, but it has two problems:

  • it reaches past the backend abstraction into Action Scheduler directly;
  • a provisional action exists for a few milliseconds before it is replaced. Its due time is time() + stagger, which can be close to now, so a queue runner could claim it in that window.

Proposal

Add an optional first_run (int Unix timestamp) arg to WP_Agent_Routine for interval routines:

  • register() uses first_run (when it is in the future) instead of time() + stagger_offset() only when it mints a new chain;
  • first_run is not schedule-significant. recurrence_matches() keeps comparing only interval/expression, so a relative anchor recomputed on every boot never causes churn;
  • stagger_offset() returns 0 when first_run is set;
  • to_array() exposes it.

After that ships, data-machine can drop its workaround and pass first_run straight through from FlowRoutines::system_routine_args().

主要言語
PHP
スター
33
フォーク
9
平均マージ
36分
マージ済み PR(30日)
13

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Automattic/agents-api のほかの issue

Automattic/agents-api の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。