Skip to content

Heartbeat: pre-check publish_date before dispatching Publisher worker #5

Description

@aleks1k

Problem

Currently the heartbeat dispatches a Publisher worker for any issue in To Publish queue, regardless of publish_date. The Publisher then reads the date, sees it's in the future, and calls work_finish(blocked) — wasting tokens.

What's needed

In the heartbeat dispatch logic (before a Publisher worker is spawned), read publish_date from the issue body and skip dispatch if the date is in the future.

Implementation

In lib/services/heartbeat/tick-runner.ts (or the queue dispatch loop), add a pre-check for publisher role:

// Before dispatching Publisher:
if (role === "publisher") {
  const publishDate = extractPublishDate(issue.description);
  if (publishDate && publishDate > new Date()) {
    // Skip — not yet time to publish
    continue;
  }
}

extractPublishDate() should parse publish_date: YYYY-MM-DD from issue body (same pattern as analytics-trigger's extractPublishedAt).

Bonus: GitHub Projects field

If GitHub Projects v2 is set up (issue #4), also check the Publish Date field value on the project item — more reliable than parsing issue body text.

Notes

  • Must not affect other roles — only skip Publisher dispatch
  • If publish_date is absent or invalid: dispatch normally (ASAP)
  • Log skipped dispatches to audit log with reason "scheduled: publish_date not yet reached"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions