Skip to content

feat(admin-console): queue position per run from the device queue, and a requeue event (CHE-10263) [squash] - #350

Open
congvc-bot-x99[bot] wants to merge 2 commits into
mainfrom
agent/x99-claude-sonnet/che-10263-d788fb68e35c
Open

congvc-bot-x99[bot] wants to merge 2 commits into
mainfrom
agent/x99-claude-sonnet/che-10263-d788fb68e35c

Conversation

@congvc-bot-x99

@congvc-bot-x99 congvc-bot-x99 Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Status

Draft. Waiting on cross-lab agent review and CI checks on head aa872e9fd5880c3607abebdb699e2aff6e499186. Delivers stage 1 of CHE-1134 (B5a-2).

Conditions

  • Position 1 means next to start on its device. The run that holds the lock is not counted.
  • A requeued row gets its start_time back from created_at.
  • session_requeued is in _RUN_BOUND_EVENTS. Named streams isolate session_requeued to its own run in both Cloudflare mode and open mode.

Change

  • DeviceExecutionLock.queue_positions() (artemis/runtime/device_lock.py) maps each live ticket token to its 1-based rank. It filters dead-owner tickets before collecting target lock IDs and calling _build_device_queue. Dead pending/any or concrete tickets cannot occupy parking slots. Each token appears at most once.
  • GET /api/status (apps/admin_console/routers/tasks.py) calls queue_positions() once per request. It adds queue_position (int or null) to response copies only, leaving state.queue_items untouched.
  • TaskQueueService.requeue_starting (apps/admin_console/services/task_queue_service.py) restores start_time to created_at (or pops start_time when created_at is absent). It then broadcasts session_requeued with session_id, device_serial and queue_position. The early return when stopped emits nothing.
  • _RUN_BOUND_EVENTS (apps/admin_console/routers/tasks.py) now includes "session_requeued". Named streams enforce exact session_id matching for _RUN_BOUND_EVENTS in both Cloudflare mode and open mode. _OPEN_NAMED_STREAM_EVENTS keeps historical cross-run delivery for session_started, session_ended and background_tasks_updated in open mode.

Blast Radius

Callers: /api/status consumers receive queue_position on queue entries. Named SSE streams (/api/stream/{session_id}) receive session_requeued only for their own session_id. requeue_starting has no production caller yet until CHE-1142. Regressions surface in test_device_lock.py, test_task_queue_service.py, test_host_admission.py, test_host_nack_races.py and test_run_ownership.py. Proof level: 2.

Evidence

Red before changes:

  • Initial red on main (1f4f273ff121): 6 failed, 3 passed on the initial new tests.
  • Red on e3110dc608b8 before fix aa872e9fd588:
    • uv run pytest tests/unit/runtime/test_device_lock.py -k "queue_positions" -q -> 1 failed, 4 passed (test_queue_positions_dead_pending_and_dead_concrete_do_not_distort_parking).
    • uv run pytest tests/unit/admin_console/test_run_ownership.py -k "requeue_event or global_lifecycle_events" -q -> 2 failed, 1 passed (test_named_stream_gets_its_own_requeue_event_only, test_open_mode_named_stream_gets_its_own_requeue_event_only).

Green on aa872e9fd5880c3607abebdb699e2aff6e499186:

uv run pytest tests/unit/runtime/test_device_lock.py tests/unit/admin_console/test_host_admission.py tests/unit/admin_console/test_host_nack_races.py tests/unit/admin_console/test_task_queue_service.py tests/unit/admin_console/test_run_ownership.py -q
272 passed, 1 skipped, 9 warnings in 28.29s

uv run ruff format --check . (1049 files already formatted) and uv run ruff check . (All checks passed!) pass.

Closes CHE-10263
Refs CHE-1134

congvc-bot[bot] added 2 commits November 26, 2026 19:09
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review December 2, 2026 14:00
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.

0 participants