Skip to content

feat: Rest API endpoints from roadmap#5649

Open
sarthakNITT wants to merge 3 commits intoaden-hive:mainfrom
sarthakNITT:#5538
Open

feat: Rest API endpoints from roadmap#5649
sarthakNITT wants to merge 3 commits intoaden-hive:mainfrom
sarthakNITT:#5538

Conversation

@sarthakNITT
Copy link
Contributor

Description

  • Implements true pause/resume HTTP endpoints for the session execution API.
  • Previously, POST /api/sessions/{id}/pause was wired to handle_stop, making pause and stop identical.
  • This PR separates them into distinct behaviours with correct state management and resume guards.
  • Updated handle_resume() to check for status. If paused then run from the paused node, if cancelled then return with error telling to re start using trigger endpoint
  • handle_pause() now pause the currently running and cron future running processes and stores their id and node

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

Related Issues

Fixes #5538

Changes Made

  • execution_stream.py - Added _pause_requested: set[str] to track pause vs cancel intent. Added pause_execution() method that flags an execution as paused before cancelling its task. Updated the CancelledError handler to write status="paused" to disk when the flag is set, vs status="cancelled" for hard stops.
  • routes_execution.py - Added handle_pause() handler: calls stream.pause_execution() and runtime.pause_timers() to freeze both the live execution and any scheduled (cron) triggers. Updated handle_resume() to call resume_timers() after re-triggering, and added a 409 guard that rejects resume attempts on status="cancelled" sessions with a clear error. Rewired POST /pause route from handle_stop → handle_pause.
  • test_api.py - Added pause_execution() to MockStream, pause_timers()/resume_timers() to MockRuntime. Added test_pause_success (asserts {"paused": true} and pause_timers() called), test_resume_rejected_for_cancelled_session (asserts 409), and updated test_resume_from_session_state to assert resume_timers() is called.
  • docs/ — Updated core/framework/server/README.md (description and example for /pause), docs/server-cli-arch.md (corrected /stop label, added /pause row), docs/roadmap.md (marked pause, resume, stop, start, status endpoints as [x]).

Testing

Describe the tests you ran to verify your changes:

  • Unit tests pass (cd core && pytest tests/)
  • Lint passes (cd core && ruff check .)
  • Manual testing performed

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Screenshots (if applicable)

Add screenshots to demonstrate UI changes.

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]: Expose pause/resume controls as HTTP endpoints

1 participant