Skip to content

feat(gateway): add GET /api/v1/submissions/{id} polling endpoint - #57

Closed
Guilherme-M-Mateus wants to merge 5 commits into
stjosephsplacements:developmentfrom
Guilherme-M-Mateus:feat/get-submission-endpoint
Closed

Guilherme-M-Mateus wants to merge 5 commits into
stjosephsplacements:developmentfrom
Guilherme-M-Mateus:feat/get-submission-endpoint

Conversation

@Guilherme-M-Mateus

@Guilherme-M-Mateus Guilherme-M-Mateus commented Oct 19, 2026 •

Copy link
Copy Markdown

Closes #46

Summary

Adds a REST polling endpoint so clients that missed or outlived the SSE stream can fetch a submission's status, verdict and per-test results.

  • db.GetTestResults(ctx, pool, submissionID): reads submission_test_results ordered by test_index
  • HandleGetSubmission registered at GET /api/v1/submissions/{id} (new file internal/gateway/submission.go)
  • Unknown id → 404; DB errors → 500 (not masked as 404)
  • Submit mode omits stdout_preview/stderr_preview for non-sample tests, same rule as the worker's VERDICT event
  • OpenAPI: new path + SubmissionResponse schema

Auth: one deviation from the issue

Ownership rules mirror /api/v1/stream:

  • Authenticated: tenant + user ID must match, otherwise 404
  • Unauthenticated: run-mode only (submit mode → 401), and the stream_token from POST /api/v1/execute is required

The issue only says unauthenticated callers may access run-mode submissions. Without the token check this endpoint would bypass the UUIDv7-enumeration protection the SSE handler already has. Trade-off: the token TTL is 30 min, so unauthenticated polling stops working after that. Happy to change this if you'd prefer otherwise.

Tests

  • internal/gateway: invalid id → 400, DB down → 500, preview filtering (submit vs run, JSON key absent)
  • internal/db: GetTestResults round-trip in TestInsertResultsAndVerdict (testcontainers, Postgres 18)

Local gate (after merging latest development): go build, go vet, gofmt -s, and go test -race -count=1 ./... all pass. golangci-lint v2.15.0 reports 0 issues on the lines this PR changes (--new-from-rev origin/development).

Heads-up, unrelated to this PR: on current development, .golangci.yml doesn't load under v2.15.0 (can't load config: goimports is a formatter). In v2, goimports and gofmt belong under formatters: rather than linters.enable, so the lint job will probably fail on every branch until that's moved. With that fixed locally, lint shows 4 pre-existing findings (3× errcheck in internal/queue/pubsub_test.go, 1× whitespace in InsertResultsAndVerdict). I've left them out of this PR to keep it to one concern.

Design invariants

None touched. This is a read-only endpoint: no inserts, enqueues, SSE subscription/replay changes, or verdict writes. Insert-before-enqueue, subscribe-before-replay, cancel-safe writes and CAS verdict writes are unaffected.

🤖 Generated with Claude Code

Lets clients that missed or outlived the SSE stream fetch a submission's
status, verdict and per-test results.

- db.GetTestResults: read stored per-test results ordered by test_index
- Ownership rules match /api/v1/stream: authenticated callers must own the
  submission; unauthenticated callers may only read run-mode jobs and must
  present the stream_token (prevents UUIDv7 enumeration)
- Submit mode omits stdout/stderr previews for non-sample tests, same rule
  as the worker's VERDICT event
- Unknown id -> 404; DB errors -> 500 (not masked as 404)
- Tests for handler, preview filtering, and GetTestResults; OpenAPI spec

Closes stjosephsplacements#46

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: stjosephsplacements/AetherCode-Execution-Engine/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 7e60cb32-b4b7-47fd-af59-340c7f89e08e
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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