Skip to content

feat(cli): add autosubmit scheduling for submit#351

Open
dmego wants to merge 3 commits intojunhoyeo:mainfrom
dmego:feat-autosubmit-scheduling
Open

feat(cli): add autosubmit scheduling for submit#351
dmego wants to merge 3 commits intojunhoyeo:mainfrom
dmego:feat-autosubmit-scheduling

Conversation

@dmego
Copy link
Copy Markdown

@dmego dmego commented Mar 21, 2026

Closes #123

Summary

  • add tokscale autosubmit enable|disable|status|run
  • reuse existing submit filters while keeping --dry-run unavailable in autosubmit
  • persist autosubmit config in settings.json
  • add scheduler integration:
    • macOS: launchd
    • Linux: systemd --user, with cron fallback
    • Windows: Task Scheduler
  • add lock / rollback / degraded-status / orphan-scheduler / minimal-log coverage

Details

  • autosubmit run reuses submit behavior while keeping autosubmit logs minimal
  • autosubmit status reports both saved config state and live scheduler state
  • autosubmit disable can clear unsupported or orphaned scheduler configurations
  • persisted dryRun values are sanitized out before autosubmit execution
  • machine-readable submit error extraction is used for autosubmit failure reasons
  • macOS launchd now runs tokscale directly instead of /bin/sh

Validation

  • cargo test --package tokscale-cli autosubmit -- --nocapture
  • verify CLI contracts:
    • cargo run -p tokscale-cli -- submit --help
    • cargo run -p tokscale-cli -- autosubmit enable --help
    • cargo run -p tokscale-cli -- autosubmit enable --interval 2h --dry-run
  • optional platform smoke test:
    • enable
    • status
    • scheduler inspection (launchctl / systemctl --user / schtasks)
    • disable

Summary by cubic

Add autosubmit scheduling to tokscale submit, with enable/status/disable/run and robust cross‑platform scheduler and status handling. Hardened config parsing, interval validation, and recovery to handle invalid configs and orphaned jobs.

  • New Features

    • New tokscale autosubmit enable|disable|status|run.
    • Reuses submit filters; --dry-run blocked for autosubmit and sanitized before execution.
    • Persists config in settings.json; status shows saved config and live scheduler state (degraded/orphaned), and disable can clear unsupported/orphaned scheduler entries.
    • Scheduler integration: launchd (macOS), systemd --user with cron fallback (Linux), Windows Task Scheduler; macOS now runs tokscale directly via launchd.
    • Minimal autosubmit logs; lock/rollback/stale-lock protection; machine-readable submit error extraction.
    • Updated READMEs (EN/JA/KO/ZH) and expanded CLI tests for autosubmit and CLI contracts.
  • Bug Fixes

    • Hardened autosubmit config parsing and interval handling: only Nh|Nd, positive integers, invalid units/zero rejected, extreme values capped.
    • Safer settings.json loading and recovery for invalid autosubmit config; improved status detection and cleanup of orphaned/unsupported scheduler jobs.

Written for commit f647cfe. Summary will update on new commits.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 21, 2026

@dmego is attempting to deploy a commit to the Inevitable Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

5 issues found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/tokscale-cli/src/tui/settings.rs">

<violation number="1" location="crates/tokscale-cli/src/tui/settings.rs:33">
P2: Using command-layer `AutosubmitConfig` directly in settings creates brittle serialization that can silently reset all user settings on schema changes. The type lacks serde defaults, and `load()` uses `unwrap_or_default()` which discards all settings (not just autosubmit) if any field fails to deserialize. Consider adding serde defaults to `AutosubmitConfig` fields or using a separate settings-layer DTO with explicit migration/validation logic.</violation>
</file>

<file name="crates/tokscale-cli/src/main.rs">

<violation number="1" location="crates/tokscale-cli/src/main.rs:898">
P1: Add #[serde(default)] to all boolean fields in SubmitFilterArgs to prevent deserialization failures when config fields are missing</violation>
</file>

<file name="crates/tokscale-cli/src/commands/autosubmit.rs">

<violation number="1" location="crates/tokscale-cli/src/commands/autosubmit.rs:134">
P2: Unbounded interval values may cause chrono timestamp overflow/panic. The `parse_interval_spec` function accepts any u32 value without upper bound validation. Values like u32::MAX days (~4.3 billion days, ~11.7 million years) exceed chrono's DateTime representable range and will cause a panic when added to a timestamp in `is_due()`. Consider enforcing a reasonable maximum interval (e.g., 365 days or 10 years) during parsing.</violation>

<violation number="2" location="crates/tokscale-cli/src/commands/autosubmit.rs:704">
P2: Duplicate manual flag mappings in submit_args_to_cli_args and format_submit_args can diverge from SubmitFilterArgs definitions, causing autosubmit behavior mismatches</violation>
</file>

<file name="README.ja.md">

<violation number="1" location="README.ja.md:433">
P2: Missing `autosubmit run` command in Japanese README documentation. The autosubmit feature supports commands `enable|disable|status|run` but the Japanese documentation only lists `enable`, `status`, and `disable`, making the `run` command undiscoverable for Japanese users who rely on localized documentation.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

4 issues found across 7 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="README.ko.md">

<violation number="1" location="README.ko.md:440">
P3: Autosubmit docs are internally inconsistent: the synopsis omits `tokscale autosubmit run` while the added bullet claims it exists.</violation>
</file>

<file name="README.md">

<violation number="1" location="README.md:443">
P2: README autosubmit synopsis is internally inconsistent: it omits the documented `autosubmit run` subcommand, which can mislead users about available CLI commands.</violation>
</file>

<file name="README.ja.md">

<violation number="1" location="README.ja.md:441">
P2: Autosubmit docs are internally inconsistent: `run` is documented in bullets but missing from the command synopsis block.</violation>
</file>

<file name="crates/tokscale-cli/src/tui/settings.rs">

<violation number="1" location="crates/tokscale-cli/src/tui/settings.rs:76">
P1: `Settings::load()` now drops `autosubmit` on any strict-load failure, which can silently disable and later persistently erase autosubmit config.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

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.

Feature: Auto-submit

1 participant