Skip to content

[Feature] : API ENDPOINTS PR 3 : System Status and Run Management Endpoints#1132

Open
pulk17 wants to merge 5 commits into
CCExtractor:masterfrom
pulk17:api-pr3-system
Open

[Feature] : API ENDPOINTS PR 3 : System Status and Run Management Endpoints#1132
pulk17 wants to merge 5 commits into
CCExtractor:masterfrom
pulk17:api-pr3-system

Conversation

@pulk17

@pulk17 pulk17 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

[FEATURE]

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

My familiarity with the project is as follows (check one):

  • I have never used the project.
  • I have used the project briefly.
  • I have used the project extensively, but have not contributed previously.
  • I am an active contributor to the project.

System status and run management endpoints (PR 3/6)

Summary

Part 3 of 6 (supersedes #1117). Adds health/queue endpoints and the CI run
lifecycle, and restores the global middleware integration tests deferred from
PR 1 now that there are endpoints to test against.

Stacking: stacked on PR 2 (#1131). Please review #1131 first.

System (mod_api/routes/system.py)

  • GET /system/health — unauthenticated; DB / local-storage / GCS status
    (503 only when down).
  • GET /system/queuesystem:read; queued + running jobs with
    queue_depth/running_count, ?platform/?status filters.
  • GET /runs/{id}/artifactsresults:read; lists run artifacts across local
    disk and GCS. Path traversal blocked by safe_resolve. (Binary/coredump/
    combined-stdout artifacts are produced by the CI-VM work; until that ships
    they report storage_status: "missing".)

Runs (mod_api/routes/runs.py)

  • POST /runsruns:write; creates a run for a commit + platform. Main-repo
    runs need contributor/tester/admin; fork runs require the caller to own the
    fork (see dependency note). Rejects commits with no build artifact up front
    (fails open if GitHub is unreachable).
  • GET /runsruns:read; filter by platform/branch/commit/repo/date,
    sortable, paginated. Status filtering covers queued/running/canceled at
    the DB level; terminal-state filtering is intentionally not offered and
    returns a clear 400.
  • GET /runs/{id} · /summary · /progress · /config — detail, aggregate
    pass/fail/skip/missing/error counts, progress timeline, launch config.
  • POST /runs/{id}/cancelruns:write + contributor/tester/admin; writes a
    canceled progress row that the worker honours. Idempotent. Any runs:write
    user may cancel any run by design in this shared CI.

Services

storage.py (local/GCS resolution + signed URLs), error_service.py (derives
structured + infra errors), utils.safe_resolve (realpath traversal guard).

Dependency note (please read)

Fork-run permission uses user.github_login, which is populated in PR 6
(OAuth callback + a lazy fallback in this endpoint). This stack should therefore
be merged/deployed together; pre-existing users populate github_login on their
next GitHub login.

Testing

137 tests across tests/api, including the restored middleware integration
tests and permission-boundary assertions. Lint/type clean.

Next

PR 4 (#1133): samples and regression-test endpoints.

@pulk17 pulk17 changed the title API ENDPOINTS PR 3 : System Status and Run Management Endpoints [Feature] : API ENDPOINTS PR 3 : System Status and Run Management Endpoints Jun 24, 2026
@cfsmp3 cfsmp3 self-requested a review June 24, 2026 16:40

@cfsmp3 cfsmp3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HIGH:

  • H2 — the C1 fix is only half-wired. The expected_outputs fix went into batch_get_run_data (run status), but get_run_summary and error_service still call the legacy is_dummy_row path (never matches). So for a run with missing output: derive_run_status says fail (right), but /summary counts it as pass with missing_output_count: 0, and /errors omits it. The endpoints contradict each other, and the headline bug resurfaces in the two endpoints users actually read. No test catches it.
  • H3 — arbitrary-repo CI trigger (carryover #1117 H2). POST /runs: is_staff short-circuits ownership, repository is only regex-checked → a contributor can make the build VM clone+build any GitHub repo = arbitrary-code exec on CI infra. Gated by contributor role, but a real privilege expansion.
  • H1 — migration still absent (3 PRs deep; all these routes are auth-gated so they need the token table too).

MEDIUM: cancel race (no row lock); status-filter 1000-cap drops rows + inconsistent total; summary total_samples never reconciles; _get_output_artifacts N+1 + paginates after full build; GCS signed URLs without blob.exists.

LOW/NIT: RunSummarySchema unused (raw dict, no contract); step:None dead field; queue hand-builds pagination; generic-exception→JSON path still untested.

@pulk17 pulk17 force-pushed the api-pr3-system branch 8 times, most recently from dbf0613 to a114116 Compare June 25, 2026 16:58
@pulk17 pulk17 force-pushed the api-pr3-system branch 2 times, most recently from 2f0b3c7 to fff7f45 Compare June 26, 2026 09:02
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants