Skip to content

Add rule-drafts API with pluggable submission backends (GitHub, local)#402

Draft
julietshen wants to merge 1 commit into
roostorg:mainfrom
julietshen:julietshen/rule-drafts-api
Draft

Add rule-drafts API with pluggable submission backends (GitHub, local)#402
julietshen wants to merge 1 commit into
roostorg:mainfrom
julietshen:julietshen/rule-drafts-api

Conversation

@julietshen

Copy link
Copy Markdown
Member

Adds a ui-api blueprint for authoring SML rule drafts from the UI, with submission routed through a pluggable backend so each deployment can pick where drafts go for review.

Endpoints (all gated by a new CAN_EDIT_RULE_DRAFTS ability, granted to super_user):

  • GET /rule-drafts/source - fetch a loaded SML file
  • POST /rule-drafts/validate - splice the draft into the engine's loaded sources and re-run the same AST validation the engine uses; returns structured errors plus suggested imports
  • GET /rule-drafts/vocabulary - features, UDFs (with signatures), and in-use effects, for editor autocomplete
  • POST /rule-drafts/submit - re-validates server-side, then hands the draft to the configured backend
  • GET /rule-drafts/pending - list drafts currently in review
  • POST /rule-drafts/parse-into-builder - decide whether a file fits the form-based builder subset (used by the UI in a follow-up PR)

Backends implement the RuleSubmissionBackend Protocol and are selected by OSPREY_RULES_SUBMISSION_BACKEND:

  • null (default): every call fails fast with 503, so an unconfigured install never writes anything
  • github: opens a PR via the REST API; supports GitHub Enterprise via OSPREY_GITHUB_API_URL
  • local: writes into a mounted rules directory for deployments whose pipeline already syncs one

Adopter docs (env vars per backend) are in docs/user/manage.md.

This is the base of a stack. Follow-ups: the rule-editor UI, a GitLab backend, and a Tangled (ATProto) backend.

Checklist

  • Tests pass locally (./run-tests.sh osprey_worker/src/osprey/worker/ui_api/osprey/views/tests/test_rule_drafts.py)
  • uv run ruff check . passes
  • uv tool run fawltydeps --check-unused --pyenv .venv passes
  • Updated CHANGELOG.md

New ui-api blueprint for authoring SML rule drafts from the UI:

- /rule-drafts/source, /validate, /vocabulary, /submit, /pending,
  /parse-into-builder, all gated by a new CAN_EDIT_RULE_DRAFTS ability
- Drafts are spliced into the engine's loaded sources and re-run through
  the same AST validation the engine uses, both on validate and again
  server-side on submit
- Submission routes through a RuleSubmissionBackend Protocol selected by
  OSPREY_RULES_SUBMISSION_BACKEND: github (opens a PR via the REST API,
  supports GitHub Enterprise), local (writes to a mounted rules dir),
  and null (fail-fast default so an unconfigured install never writes)
- Adopter docs for the env vars in docs/user/manage.md

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VZ4RQtuHCCgurfpjfPXXAM
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a8538cfa-82b6-457d-8bc6-89dc3c29f7fe

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

1 participant