feat(executions): add worker_id + status__in filters and oldest_claimed_at#48
Closed
mikemolinet wants to merge 3 commits into
Closed
feat(executions): add worker_id + status__in filters and oldest_claimed_at#48mikemolinet wants to merge 3 commits into
mikemolinet wants to merge 3 commits into
Conversation
…ed_at Adds three additive surface bumps on `GET /v1/executions` to unblock pending-execution counter UIs (e.g. the menubar counter that wants to fetch `pending,delivering,retry_ready` for one worker in a single round trip): - `worker_id=` query param filters to executions claimed by that worker (`Execution.claimed_by_worker == worker_id`). - `status__in=` comma-separated multi-status filter using `Execution.status.in_([...])`. Mutex with `status=`; passing both returns 400 `conflicting_filters`. - `oldest_claimed_at` response field is the earliest `claimed_at` over the filtered set, ISO-8601 string. Null when the result count is 0 so callers can render "oldest pending: 5m" without a follow-up query. Auth scoping unchanged — every new filter applies AFTER the existing `Cue.user_id == user.id` join, so multi-tenant leak surface is identical to the pre-existing `cue_id`/`status`/`outcome_state` filters. Tests: 3 new in TestListExecutions (worker_id scoping + oldest_claimed_at value, status__in union + mutex 400, null oldest_claimed_at on empty filtered set). 59/59 in the executions suite green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Parity checkThis PR modifies files tracked in
Please confirm one of the following in a reply or PR description update:
This is a soft check — it does not block merge. The goal is visibility, not friction. See HOSTED_ONLY.md for the open-core policy. |
Collaborator
Author
|
Closing as stale — branch diverged from main by ~8872 deletions across 57 files. Rebase infeasible. Feature is still needed: Next step: re-port as fresh PR against current main HEAD ( Branch retained for reference. |
auto-merge was automatically disabled
May 11, 2026 15:33
Pull request was closed
6 tasks
mikemolinet
added a commit
that referenced
this pull request
May 11, 2026
…parity port of cueapi/cueapi#623) (#77) Re-port of closed [PR #46](#46) which was on a stale base ~8900 deletions behind main. Fresh against current main HEAD. Closes §13 / Phase 12.1.7 — messages-side complement to the cue-fire send_at shipped in PR #618 (which still needs its own re-port). ## What lands - **alembic/versions/030_message_send_at.py** (renumbered from private's 047) Adds `messages.send_at TIMESTAMPTZ NULL` + partial index `ix_messages_send_at` (WHERE send_at IS NOT NULL) built CONCURRENTLY so the index creation doesn't take an ACCESS EXCLUSIVE lock on the messages table during deploy. Existing rows default to NULL = "send now". - **app/models/message.py** — adds `send_at` Column. - **app/schemas/message.py** — `send_at: Optional[datetime]` on MessageCreate + MessageResponse. - **app/routers/messages.py** — passes `send_at=body.send_at` into `create_message`. - **app/services/inbox_service.py** — gates inbox query AND queued→delivered transition UPDATE with `send_at IS NULL OR send_at <= now()`. Scheduled messages are invisible until their time; the atomic poll-fetch transition skips them too. - **app/services/message_service.py** — `create_message` plumbs `send_at` into both `Message.send_at` and `DispatchOutbox.scheduled_at`. Past timestamps are forgiving fallback (treated as send-now). `to_response_dict` surfaces the persisted value. - **tests/test_message_send_at.py** — 7 new tests verbatim from private cueapi covering all 7 semantic paths (omitted, future-invisible, outbox-scheduled, past-fallback, becomes-visible- after-pass, sender-view-shows-it, invalid-timestamp). - **parity-manifest.json** — new entry for migration 030 under `message-send-at-port (private #623)`. ## Wire format `send_at` flows in the BODY of `POST /v1/messages` (server contract: `MessageCreate.send_at`). Same shape as cue-fire `send_at` (PR #618). NULL = send now (default). Future timestamp = inbox-gate + DispatchOutbox.scheduled_at. Past timestamp = forgiving send-now. ## Tests 7/7 new tests pass locally. Full local suite: 836 passed + 18 xfailed (pre-existing) + 3 skipped. Zero regressions. ## Sibling ports - cli, mcp, python, action sides shipped via session 2 (2026-05-10): cueapi-cli #48, cueapi-mcp #33, cueapi-python (private), cueapi-action #12. This is the cueapi-core (OSS server) side that was still missing. ## Re-port note Re-port of closed PR #46. That branch was ~8900 deletions behind main; fresh port against current main HEAD (after PR #74 + #75 merged earlier in this session).
Merged
6 tasks
mikemolinet
added a commit
that referenced
this pull request
May 11, 2026
…ed_at on list endpoint (#79) Re-port of closed [PR #48](#48) which was on a stale base ~8870 deletions behind main. Fresh against current main HEAD via direct patch from the old branch's commit (c05518c). Adds query-side enrichment to ``GET /v1/executions``: - ``worker_id=`` — filter to executions claimed by a specific worker (Execution.claimed_by_worker) - ``status__in=foo,bar,baz`` — comma-separated multi-status filter. Mutex with ``status=``; 400 conflicting_filters if both passed. - Response gains ``oldest_claimed_at`` — earliest ``claimed_at`` over the filtered set, or null when count=0. Unblocks dashboard/menubar "oldest pending: 5m" rendering without a follow-up query. ## Use cases - **Menubar pending counter**: fetch ``pending,delivering,retry_ready`` in one round trip (status__in), get total + oldest_claimed_at to render "3 in flight, oldest claimed 8m ago". - **Worker health dashboard**: filter by worker_id to scope to one worker's claims; see how stale their oldest claim is. ## Tests 3 new tests in TestListExecutions: - worker_id scoping + oldest_claimed_at value reflects earliest claimed_at over filtered set - status__in union + status/status__in mutex 400 - null oldest_claimed_at on empty filtered set 31/31 in test_execution_parity.py green. Full local suite: zero regressions. ## Re-port note Re-port of closed PR #48 (commit c05518c). Branch was ~8870 deletions behind main; fresh against current main after PR #74/#75/#76/#77/#78 merged earlier in this session. Patch applied cleanly from c05518c to current main — the patch only touches list_executions endpoint, which has remained additive (cueapi-core added outcome_state filter since the branch was cut; this PR is compatible).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per CTO ask
CTO-CUEAPI-EXEC-WORKER-FILTER— unblocks CMA's Surface 6.7 menubar pending-exec counter that wants to fetchpending,delivering,retry_readyfor one worker in a single round trip.Three additive surface bumps on
GET /v1/executions:worker_id=— filters to executions claimed by that worker (Execution.claimed_by_worker == worker_id).status__in=— comma-separated multi-status filter viaExecution.status.in_([...]). Mutex withstatus=; passing both returns 400conflicting_filters.oldest_claimed_at— new response field, earliestclaimed_atover the filtered set as ISO-8601 string. Null when count=0 so callers can render "oldest pending: 5m" without a follow-up query.Auth scoping unchanged — all new filters apply AFTER the existing
Cue.user_id == user.idjoin.Test plan
tests/test_execution_parity.py::TestListExecutions— 7/7 (4 pre-existing + 3 new):test_filter_by_worker_id— scoping +oldest_claimed_atcorrectness across two workerstest_status_in_returns_union— union behavior + 400 mutex withstatus=test_oldest_claimed_at_null_when_empty— null when filtered set is emptytest_execution_parity+test_execution_pagination+test_worker_transport)🤖 Generated with Claude Code