Skip to content

Feature/multi dimensional state - #1

Merged
tpepels merged 22 commits into
mainfrom
feature/multi-dimensional-state
Apr 17, 2026
Merged

Feature/multi dimensional state#1
tpepels merged 22 commits into
mainfrom
feature/multi-dimensional-state

Conversation

@tpepels

@tpepels tpepels commented Apr 17, 2026

Copy link
Copy Markdown
Owner

No description provided.

tpepels and others added 21 commits April 14, 2026 14:09
- Add scheduler_backend.py to handle job submission to `at` and job removal via `atrm`.
- Introduce state_model.py to define job states and invariants for job submissions.
- Create transitions.py to manage job state transitions and ensure immutability.
- Develop test cases for execution, persistence, scheduler backend, state model, and transitions to ensure functionality and correctness.
- Implement migration logic for legacy job formats to the new model.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add before/after transition output to cli_reschedule_job, cli_change_session,
cli_retry_job, and remove_job (non-interactive path). Each command now prints
a structured header (e.g. "job1: rescheduled") plus contextual notes for
at-job removal, execution state resets, and dependent job warnings. Added
can_retry guard to cli_retry_job. Tests written first (TDD): 15 new tests,
220 total passing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Print job_id/when header lines before calling apply_job_update in
cli_reschedule_job so they appear even when resubmit fails. Add tests
for cli_change_session running-job warning and cli_retry_job dependency
note.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds `cli_cancel_job` and the `cancel <id>` subcommand, which marks a job as
cancelled while keeping the record for audit trail. Guards against cancelling
running or already-cancelled jobs; removes the at job when submission=scheduled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements cli_submit_job with guards for state, prompt file existence,
and at scheduling errors, plus argparse/dispatch wiring.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…utation

Replace the manual submission/at_job_id field mutation in apply_job_update's
resubmit-failure path with a proper on_resubmit_failed transition function,
ensuring all state changes go through the transition engine.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
load_jobs now catches invariant violations per record, returning
{"id": ..., "_invalid": True, "_error": ...} sentinels instead of
crashing. cli_show_job guards against sentinels with an actionable
error message. cancel_at_job now transitions jobs to submission=queued
(instead of leaving submission=scheduled with no at_job_id) to avoid
creating invariant-violating intermediate states.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Consolidated job state model tests into a more streamlined format.
- Introduced new job creation and scheduling operations in `operations.py`.
- Added utility functions for time handling in `time_utils.py`.
- Enhanced test coverage for job transitions and state checks.
- Implemented fixtures for testing with temporary directories.
- Improved error handling and validation in job operations.
- Updated command building in `execution.py` for better formatting.
- Enhanced import organization in `operations.py` for clarity.
- Refactored job migration logic in `persistence.py` to improve readability.
- Improved script generation in `scheduler_backend.py` for consistency.
- Cleaned up state model definitions in `state_model.py`.
- Streamlined time utility functions in `time_utils.py`.
- Enhanced test structure and readability across multiple test files.
- Added CI workflow for quality checks and automated testing.
- Created Makefile for simplified development environment setup.
@tpepels

tpepels commented Apr 17, 2026

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

@tpepels
tpepels merged commit 5108c75 into main Apr 17, 2026
1 check failed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f88ffd371

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return "\n".join(
[
f"cd {shlex.quote(job['cwd'])} || exit 1",
"export PATH=/usr/local/bin:/usr/bin:/bin",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve user PATH for wrapper self-invocation

This script unconditionally resets PATH to system directories, but later in the same generated script it calls schedule-agent mark .... With the default install path (~/.local/bin), those mark commands are not resolvable under this PATH when at executes the job, so state transitions to running/done/failed can silently fail and jobs remain stuck as scheduled/missing. Keep the inherited PATH (or use an absolute path to the current schedule-agent binary) before invoking the mark subcommands.

Useful? React with 👍 / 👎.

)
migrated["created_at"] = migrated.get("created_at") or now_iso()
migrated["updated_at"] = (
migrated.get("updated_at") or (legacy_state or {}).get("updated_at") or now_iso()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Normalize migrated legacy updated_at timestamps

migrate_job stores legacy_state.updated_at verbatim into updated_at, but downstream formatting/sorting expects strict ISO timestamps with timezone (%Y-%m-%dT%H:%M:%S%z). Legacy state from prior versions can contain non-ISO values (for example YYYY-MM-DD HH:MM:SS), which means upgraded jobs load as valid but then crash list/show paths when iso_to_display parses updated_at.

Useful? React with 👍 / 👎.

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.

1 participant