Skip to content

feat: dataset proposal service and endpoint - #384

Merged
Scr4tch587 merged 17 commits into
kai/github-clientfrom
kai/dataset-proposals
Jul 28, 2026
Merged

feat: dataset proposal service and endpoint#384
Scr4tch587 merged 17 commits into
kai/github-clientfrom
kai/dataset-proposals

Conversation

@Scr4tch587

Copy link
Copy Markdown
Collaborator

What changed

`POST /api/v1/datasets` — submit a dataset proposal; the server validates it and opens a GitHub PR adding `builders/scripts///` (config.toml, builder.py, optional requirements.txt / .env.template). Nothing is written to the server's own scripts dir; the dataset goes live only after review + merge + restart.

Validation before any PR opens (`core/service/proposals.py`):

  • generates the canonical `config.toml`, then re-parses those exact bytes and runs the same `validate_config` the server runs at startup, plus registry cross-checks (deps exist, granularity ordering, start-date ordering; a new dataset is a leaf, so cycles are impossible)
  • builder script: AST check for a top-level `build(dependencies, timestamp)`, then ruff autofix + format server-side (same rule set as repo CI) so proposal PRs land pre-linted; unfixable violations reject with ruff's output
  • proposer identity is required (name, Wat Street team, discord user, description) and surfaced in the PR body along with the API key's team label

PR shape: branch `add-dataset/-`, single commit, title `feat: add dataset /`, body with field table + review checklist (including the manual-`.env` step for `env-vars` datasets — secrets are never committed, only `.env.template`). Reviewers auto-requested from `GITHUB_REVIEWERS` (default `Blackgaurd,Scr4tch587`).

Error mapping: 400 invalid submission (message safe to show in the form) · 409 dataset exists or proposal already open · 502 GitHub unreachable/misconfigured.

Deps/config: `ruff` added as a server runtime dependency (for the lint step); `GITHUB_TOKEN` / `GITHUB_REPO` / `GITHUB_REVIEWERS` documented in `infra/.env.template`.

Why

Lead-approved design: dataset creation must go through code review, not direct server writes — uploading a builder script is uploading code that executes on the server. This endpoint automates everything up to the human gate.

Benefit

A submission that passes this endpoint cannot fail CI or break server startup: the committed config is byte-identical to what was validated, the script is pre-linted, and the CI gate (#380) re-verifies on the PR. E2E-tested against a fake GitHub server and the real API.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
)
if check.returncode != 0:
raise InvalidProposalError(
f"builder script fails lint:\n{check.stdout.strip()}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI] This only captures check.stdout in the error message — check.stderr is captured (capture_output=True) but discarded entirely, never logged or surfaced. Normally ruff writes its violation list to stdout, but if the subprocess fails for a different reason (an internal ruff error, an isolated-config resolution issue, etc.), the real diagnostic ends up on stderr and gets silently swallowed — the user (and the backend log, since routes.py just logs str(e)) is left with an unhelpful "builder script fails lint:\n" and nothing else. Worth including check.stderr in the raised message too, e.g. f"builder script fails lint:\n{(check.stdout + check.stderr).strip()}".

Scr4tch587 and others added 3 commits July 27, 2026 22:06
docs: document dataset proposal flow in specs
…ordances

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Scr4tch587 and others added 2 commits July 27, 2026 22:43
feat: api client support for dataset proposals
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Scr4tch587
Scr4tch587 merged commit e08c0aa into kai/github-client Jul 28, 2026
5 checks passed
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