[Feature] : API ENDPOINTS PR 3 : System Status and Run Management Endpoints#1132
Open
pulk17 wants to merge 4 commits into
Open
[Feature] : API ENDPOINTS PR 3 : System Status and Run Management Endpoints#1132pulk17 wants to merge 4 commits into
pulk17 wants to merge 4 commits into
Conversation
|
cfsmp3
requested changes
Jun 24, 2026
cfsmp3
left a comment
Contributor
There was a problem hiding this comment.
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.
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.



Please prefix your pull request with one of the following: [FEATURE] [FIX] [IMPROVEMENT].
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Feature: System Status and Run Management Endpoints (PR 3/6)
Executive Summary
This Pull Request is Part 3 of 6 in the initiative to introduce a fully-featured JSON REST API (superseding #1117).
This PR introduces the core domain logic for the platform: System Status Monitoring and CI Run Management. It enables CI runners and users to check platform health, fetch the available job queue, trigger new CI runs, and retrieve rich summaries of completed runs. Notably, this PR also re-introduces the global middleware tests which were deferred from PR 1, as the endpoints they test against now exist.
Architectural Additions & Enhancements
1. System Endpoints (
mod_api/routes/system.py)Mounted at
/api/v1/system, this router exposes global platform capabilities:GET /health: Unauthenticated endpoint for load balancers and up-time monitors to verify API responsiveness.GET /queue: Allows CI runners with thesystem:readscope to query pending tests, with optional platform filtering (?platform=windows).GET /runs/<run_id>/artifacts: Given a completed run ID, this resolves and lists all accessible artifacts (logs, test outputs) checking both local disk and Google Cloud Storage (via the newly addedstorageservice).2. Run Management Endpoints (
mod_api/routes/runs.py)Mounted at
/api/v1/runs, this handles the core CI lifecycle:POST /(Trigger Run): Allows users/bots withruns:writeto trigger a new CI test run on specific commits. Enforces permissions (users can only trigger tests for their own forks unless they have admin/contributor status).GET /(List Runs): Cursor and offset paginated retrieval of historical CI runs with advanced filtering (?status=running,?platform=linux).GET /<run_id>/summary: Aggregates a comprehensive JSON summary of a specific run, computing completion status, calculating duration, and aggregating infrastructure vs test failures (via the newerror_service).POST /<run_id>/cancel: Securely aborts a running CI job.3. Supporting Services
storage.py: Handles cross-environment artifact resolution (Local file paths vs Google Cloud Storage blobs).error_service.py: Parses raw test results to deterministically attribute failures to either "infrastructure errors" (e.g. out of memory, timeout) or actual "test regressions".utils.py: Introduces pagination helpers and a highly secure_safe_resolveutility to prevent Path Traversal attacks when reading artifacts.Testing & Quality Assurance
This PR significantly expands the active test suite:
test_middleware_auth,error_handler,rate_limit,validation) deferred from PR 1 have been introduced and perfectly pass against the new system routes.tests/apidirectory.isort,pydocstyle,pycodestyle, andmypypass without errors.Next Steps
Following the review and merge of this PR, PR 4 (Samples & Baseline Approvals) will be submitted, exposing endpoints to interact with individual media samples and manage baseline updates.