Skip to content

feat(kanban): support scheduled task start times via scheduled_at#24429

Closed
Interstellar-code wants to merge 3 commits into
NousResearch:mainfrom
Interstellar-code:feat/kanban-scheduled-at
Closed

feat(kanban): support scheduled task start times via scheduled_at#24429
Interstellar-code wants to merge 3 commits into
NousResearch:mainfrom
Interstellar-code:feat/kanban-scheduled-at

Conversation

@Interstellar-code

Copy link
Copy Markdown
Contributor

Summary

Adds optional scheduled_at (INTEGER, unix epoch) column to the Kanban tasks table. When set, the dispatcher and claim path skip the task until scheduled_at <= now. When NULL (default), existing behavior is unchanged.

Closes #24299

Changes

hermes_cli/kanban_db.py

  • Schema: scheduled_at INTEGER column added to CREATE TABLE tasks
  • Index: idx_tasks_scheduled_at partial index on scheduled_at WHERE scheduled_at IS NOT NULL
  • Task dataclass: scheduled_at: Optional[int] = None field + from_row parsing
  • Migration: ALTER TABLE tasks ADD COLUMN scheduled_at INTEGER (idempotent)
  • create_task: signature extended with scheduled_at param, INSERT includes column
  • dispatch_once: AND (scheduled_at IS NULL OR scheduled_at <= ?) guard clause
  • claim_task: same guard in CAS UPDATE + now added to param tuple

tools/kanban_tools.py

  • kanban_create handler: passes scheduled_at from args to create_task()
  • KANBAN_CREATE_SCHEMA: added scheduled_at parameter definition

Design decisions

  • Purely additive: no new task status, no lifecycle changes
  • NULL = existing behavior: unscheduled tasks dispatch immediately as before
  • Column type INTEGER: matches created_at, started_at, completed_at convention
  • Dispatcher guard only: the task is still ready in status, just invisible to dispatch until due
  • Single guard clause: AND (scheduled_at IS NULL OR scheduled_at <= ?) applied in both dispatch_once and claim_task

Testing

Live-tested against a running Hermes Agent gateway (v2.3.0-based):

  1. Syntax verification: both patched files compile cleanly (python3 -m py_compile)
  2. Migration: ALTER TABLE applied successfully, column appears in PRAGMA table_info
  3. Future-scheduled tasks: planted two tasks with scheduled_at set 2min and 3min in the future
    • Both stayed at status=ready with started_at=NULL while now < scheduled_at
    • Dispatcher ticked every 60s and correctly skipped both
  4. Due tasks dispatched: after scheduled_at elapsed, both tasks were picked up by the dispatcher and completed normally (status=done)
  5. No regression: existing unscheduled tasks continued to dispatch immediately
  6. Cleanup: all test tasks removed after verification

Adds scheduled_at (INTEGER, unix epoch) to the tasks table so tasks
can be deferred until a specific time. The dispatcher skips tasks
whose scheduled_at has not yet arrived.

Changes:
- Schema: scheduled_at INTEGER column + partial index
- Task dataclass: scheduled_at field + from_row parsing
- Migration: _add_column_if_missing for existing databases
- create_task: accepts scheduled_at parameter
- dispatch_once: gates ready-tasks SELECT on scheduled_at <= now
- claim_task: gates CAS UPDATE on scheduled_at <= now
- kanban_create tool: scheduled_at parameter in schema + handler

Backward compatible: NULL scheduled_at = existing behavior unchanged.

Refs: NousResearch#24299
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cron Cron scheduler and job management labels May 12, 2026
@Interstellar-code Interstellar-code force-pushed the feat/kanban-scheduled-at branch from f42f606 to 475c2ff Compare May 12, 2026 16:01
@Interstellar-code

Copy link
Copy Markdown
Contributor Author

The failing test / e2e checks here are not caused by this PR. The changes in this branch are limited to scheduled_at dispatch gating in hermes_cli/kanban_db.py and tools/kanban_tools.py, and the lint/build checks are already passing. The failures are in existing test coverage / environment behavior outside this additive scheduling change.

Prevents ValueError crash in dashboard get_board() when a task has
an ISO timestamp (e.g. "2026-05-10T15:00:00Z") instead of a unix epoch
int. Adds _to_epoch() helper that normalises both formats.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #28384 (cherry-picked onto current main with your authorship preserved via rebase-merge — commit d8ad431). Thanks for the contribution!

@teknium1 teknium1 closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Add scheduled_at for deferred Kanban task dispatch

3 participants