Skip to content

feat(devkitd): add persistent scheduled agent sends - #502

Open
codeaholicguy wants to merge 1 commit into
mainfrom
feature-scheduled-sends
Open

codeaholicguy wants to merge 1 commit into
mainfrom
feature-scheduled-sends

Conversation

@codeaholicguy

Copy link
Copy Markdown
Owner

Closes #482

Summary

Adds persistent one-shot scheduled agent message delivery owned by devkitd, with fire-time target resolution, exact terminal pane delivery, restart/sleep late/skip handling, daemon RPC methods, and CLI commands.

What Changed

  • Storage & Timestamp Parsing (rust/crates/devkit-core):
    • Added scheduled_sends SQLite table in daemon.db with partial pending index (idx_scheduled_sends_pending_due), zero-chrono strict RFC3339/ISO-8601 UTC parser (parse_iso8601_utc_ms), short sch_<8-hex> IDs, 64 KiB payload cap, atomic state transitions (pending -> sent | late | cancelled | failed | skipped), and amortized terminal-row pruning (1,000 rows / 30 days).
    • Added wire protocol types (ScheduledSend, ScheduleCreateParams, ScheduleListParams, ScheduleCancelParams) with generated ts-rs TypeScript bindings in packages/daemon-client/src/gen/.
  • Delivery Engine, RPC & Scheduler (rust/crates/devkitd):
    • Added TmuxRuntime::pane_for_pid (TTY-to-%pane_id matching), TmuxRuntime::send_to_pane (load-buffer via stdin + paste-buffer -p -d + 150ms + send-keys Enter + buffer cleanup on failure), and HerdrRuntime::send_prompt, all with bounded subprocess timeouts.
    • Added scheduler.rs: fire-time target lookup by exact agent_name (registry + unique enriched live fallback; rejects dead/tombstoned/ambiguous/durable targets), HybridDeliverer (herdr -> exact tmux pane -> narrow ai-devkit agent send --id <name> --stdin fallback for unmanaged terminals), unified late/skip policy (<= 1h overdue -> late, > 1h -> skipped), sequential (due_at ASC, id ASC) execution, and in_flight_schedules cancel guard.
    • Added schedule.create, schedule.list, and schedule.cancel RPC handlers (rpc/schedule.rs) and a dedicated 2s tokio::time::interval scheduler loop spawned after socket bind in server.rs.
  • Daemon Client & CLI (packages/daemon-client, packages/cli):
    • Added createSchedule, listSchedules, and cancelSchedule to DaemonClient.
    • Added parseDurationMs and parseFutureIsoTimestamp in packages/cli/src/util/time.ts.
    • Added AgentScheduleService (daemon-only, matching AgentGroupService), extended agent send with --in <duration> and --at <iso-8601> (with upfront durable-target rejection and non-fatal warning when target is not currently live), and added agent schedule list and agent schedule cancel <id>.
  • Lifecycle Docs: Added requirements, design, planning, implementation, and testing docs in docs/ai/*/2026-11-25-feature-scheduled-sends.md.

Validation

All checks were run fresh after rebasing onto origin/main (f8860ede):

  • Formatting: npm run fmt:check (oxfmt --check packages + cargo fmt --all -- --check) — exit 0
  • Lint & Clippy: npm run lint (6 Nx lint tasks) and cargo clippy --workspace --all-targets -- -D warnings — exit 0
  • Build: npm run build and cargo build -p devkitd — exit 0
  • TypeScript Tests:
    • packages/daemon-client: npx vitest run — exit 0 (5/5 files, 30/30 tests passed)
    • packages/cli: npx vitest run — exit 0 (120/120 files, 1573/1573 tests passed)
  • Rust Tests: cargo test --workspace — exit 0 (222/222 tests passed, 0 failed)
  • Feature Doc Lint: node packages/cli/dist/cli.js lint --feature scheduled-sends — exit 0 (12/12 checks passed)
  • End-to-End Smoke Test (disposable sandbox):
    • Isolated HOME, TMUX_TMPDIR, unset TMUX, and freshly built devkitd + packages/cli/dist/cli.js (never touching default daemon or tmux server).
    • Verified multi-pane exact-TTY delivery (--in 2s delivered to target pane %1 while active decoy pane %0 remained empty; status transitioned to sent with sentAt).
    • Verified --at <future>, agent schedule list (filtered JSON + human table), agent schedule cancel, duplicate cancel rejection, and not_found cancel rejection.
    • Verified non-existent target stderr warning under --json and failed transition with explicit reason at fire time.
    • Verified devkitd restart recovery: 5m overdue row delivered as late to target pane; 2h overdue row marked skipped without delivery.
    • Verified CLI flag validation (--in+--at, --group+--in, --wait+--in).

Risks / Follow-ups

  • None blocking. Non-blocking follow-up noted in implementation doc: tightening the microsecond window between in_flight_schedules check and SQLite UPDATE in schedule.cancel if concurrent cancel-at-exact-fire-time races ever become relevant.

This branch has not been deployed

No deployments
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.

feat(devkitd): scheduled agent sends — deliver a message to an agent at a future time

1 participant