Skip to content

How SupaCloud integrates with a spec-driven project

A spec-driven project keeps its behaviour in versioned specs and its work in small contracts that bind to spec clauses. People decide before the work, gates decide after it, and an orchestrator runs the loop in between. SupaCloud is meant to be that orchestrator. This page explains where it plugs in, what each integration point does in the code on main today, and what is still to be built. The decision behind it is ADR 0075; the files are in Delivery spec format, the work-item side and the labels in Spec readiness contract.

requirement catalogue what the product must offer
│ a clause cites what it satisfies
domain spec (specs/<dom>/) how it behaves: clauses, parameters, scenarios, decisions
│ G1 decisions answered ──► status design-approved
work items (WI-*.yaml) which slice comes next: spec_refs, decision_refs, verifies
│ readiness ──► tracker labels ready / blocked / spec-ready [1 intake]
agent run tier-routed, on an approved slice [2 dispatch]
│ a gap ──► question ──► answer ──► decision ──► spec patch [3 question, 4 briefs]
pull request + evidence CI, spec gate, audit, independent review
│ every required check green on the same head SHA ──► merge [5 merge]
spec contract validated, traced, viewed [6 contract]

A lower layer never silently changes a higher one. A gap found while implementing becomes a question in the spec, not an assumption in code, and the answer comes back as a decision that is merged like any other change.

What the loop needs. Readiness is a fact computed from the repository: dependencies closed, referenced decisions approved, referenced specs design-approved or later. SupaCloud computes it, writes the ready, blocked, spec-ready and human-gate labels as the project’s only tracker writer, and dispatches exactly the spec-ready items.

Today. SupaCloud reads labels and dispatches by a rule set over them (SC-2); it does not write them.

  • The Forgejo issue it deserialises carries labels, milestone, assignees and updated_at besides the issue’s identity, state and body (server/crates/sc-forge/src/git/forgejo.rs:109-119).
  • Intake runs on a scan every 300 seconds (SCAN_TICK_SECONDS, re-exported at server/crates/sc-svc-backlog/src/backlog/mod.rs:27) that lists only the issues updated since its cursor between full sweeps (server/crates/sc-svc-backlog/src/backlog/intake.rs:19-22), and on the forge issues webhook, which runs the same upsert and transition for one issue (server/crates/sc-svc-backlog/src/backlog/intake_webhook.rs:32).
  • The backlog arm’s source_filter holds the rule set: readiness_source (the classifier or the labels), require_all, require_any, forbid_any, milestone_in, priority_from_labels, route_by_label (hold the item, or choose its profile and tier) and on_label_loss_in_flight (server/crates/sc-svc-orchestration/src/backlog_contract/intake_rules.rs:7-21). A malformed rule set is refused on write with a 422; one read nevertheless holds every open item as rules_invalid (intake_rules.rs:26-29). An item whose labels fail is held, and an item whose issue closes is cancelled (intake_rules.rs:392-410). The merge gate checks the rule set again before it merges (intake_allows_merge, intake_rules.rs:479).
  • sc-forge has no call that writes a label, so readiness labels come from the project’s own tooling.

Planned (with SC-20). The owner decision of 2026-09-22 makes SupaCloud the only label writer: it derives readiness from the work-item contracts and specs itself — the reference implementation is bw-fm27 tools/workitems/sync.py (compute_ready, compute_spec_ready, load_spec_state) — and maintains the ready, blocked, spec-ready and human-gate labels through the project’s existing forge connection (resolve_forge_for_project, server/crates/sc-svc-projects/src/projects/credentials.rs:426, is the credential path the merge already uses). No bot account, no CI secret.

What the loop needs. Work items and routing name a capability tier, never a model. The calibrator decides which model stands behind each tier from measured evidence.

Today. Work launches name a tier (SC-3). The launch tiers are flagship, balanced, fast and independent_review (server/crates/sc-kernel/src/model_tier.rs:44-53), with the spelling independent-review accepted, and the calibrator writes and auto-applies ordered tier chains (ADR 0068; server/crates/sc-svc-calibration/src/calibration/auto_apply.rs).

  • An agent profile’s model policy is manual, fixed, auto or tier (server/crates/sc-persistence/src/models/agent_profile.rs:23-33); a pipeline stage carries a tier, resolved at step launch to the first reachable entry of the workspace’s chain, so a calibration apply reaches queued work. A stage model wins over the stage tier, which wins over the label route and the profile’s policy (server/crates/sc-svc-orchestration/src/auto_developer_pipeline.rs:240-246).
  • A task launch whose tier has no reachable entry is refused with a 422 naming the tier (server/crates/sc-svc-tenancy/src/workspaces/tier_resolve.rs:232-235); a backlog item stays queued with tier_unreachable:<tier> instead of falling back to the runner default (server/crates/sc-persistence/src/queries/backlog_tier.rs:1-3).
  • A backlog arm asks for up to three review slots besides the forensic audit (pipeline_config.reviews), each bound at launch to a model whose vendor differs from the implementer’s; no eligible model fails the slot closed (SC-4, server/crates/sc-kernel/src/review_slots.rs:6-12). A slot runs on independent_review or security_review, and a security_review slot becomes required when the diff touches the SC-5 path classes it names (server/crates/sc-svc-orchestration/src/review_slots_schema.rs:30-41).
  • security_review is a calibrator lane with its own evidence (server/crates/sc-kernel/src/model_tier.rs:66-69). Its approval is posted as a forge review of the head through the configured review identity, which clears the reference implementation’s security-review gate classes (server/crates/sc-svc-backlog/src/backlog/review_gate_approval.rs:4-9); its request for changes blocks the item as security_review_escalated for the owner (server/crates/sc-svc-orchestration/src/backlog_contract/ci_gate.rs:55-56).

3. The question gate and write-back into decisions.yaml

Section titled “3. The question gate and write-back into decisions.yaml”

What the loop needs. An agent that hits a real gap asks instead of guessing. The item parks without holding a slot, the owner answers on any surface, the item resumes with the answer, and the answer becomes a decisions.yaml entry through a pull request.

Today. question.ask takes a question of up to 4,096 bytes with up to 8 choices (server/crates/sc-svc-exec/src/question_ask.rs:40,44) and a blocking wait of up to 600 seconds (:36), answered in the web inbox, on the Telegram or Discord card, or by the coordinator that delegated the task. A deferred ask returns at once and records the answer as a durable mailbox message (server/crates/sc-svc-exec/src/mailbox/question.rs), which is queued and never revives a finished task (ADR 0074 D6).

  • A backlog implement task parks with question.ask {mode:"park"} (SC-10): the item moves from in_progress to awaiting_answer, the agent pushes its work in progress and ends, and the run is cancelled so the audit never starts and the concurrency slot frees (server/crates/sc-svc-backlog/src/backlog/question_gate.rs:5-10).
  • The answer moves the item back to queued with a resume_context and launches nothing; the dispatcher’s gate stack (kill switch, budget, quiet hours, concurrency) starts the next round (question_gate.rs:11-14). A person who moves the item out of awaiting_answer on the board ends the parked round (question_gate.rs:15-17).
  • The project’s question_policy resolves project ?? workspace ?? built-in park (server/crates/sc-svc-backlog/src/backlog/question_policy_settings.rs:1-8).
  • A parked question has no deadline: by the owner’s ruling (#1164) a gate a person decides waits for that person, and after 24 hours every surface that shows the question says so (question_gate.rs:19-24).
  • Nothing writes an answer into the issue or the repository.

Planned (SC-20 requirement 7). When the project has a spec source, the answer produces a decisions: entry that references the question, delivered either in the item’s next implement pull request or as a separate coordinator pull request — never pushed to the default branch.

What the loop needs. Design decisions are answered in batches before the work: one brief per domain, each item with its options, a recommended option, the rationale and drafts (tables, diagrams, before/after screenshots, prototypes). The recommendation is pre-selected for convenience, but a pre-selected option counts as an answer only when the owner confirms it — per item, or with “accept all open recommendations”. Hand-over is refused while a blocking item is open. Answers are written into decisions.yaml by pull request.

Today. Nothing. The structured human-input channels are question.ask, one question at a time, and artifact page forms (server/crates/sc-svc-mcp/src/mcp/handlers_artifact_forms.rs), which have no options, recommendations or sinks. The first spec pilot (bw-fm27, club economy, 26 decisions) was answered on a questionnaire page outside SupaCloud and transferred into the repository by hand.

Planned (SC-29 v2; its brief is blueprints/SC-29.md in the pack of issue #1448). A brief page with progress, per-item state (open, as recommended, changed), eleven item types from single_choice to visual_signoff, a catalogue of draft kinds, producers (an MCP publish tool, capture integration, automatic briefs for a spec pull request that adds proposed decisions), and sinks — repo_file for decisions.yaml, issue, memory, run (release parked runs) and webhook.

What the loop needs. Nothing merges until every required check of the target repository is green on the same head SHA — the project’s CI, its spec gate, and the gate-class status that only an owner approval turns green — plus the audit and the required review slots.

Today. Two verdicts decide a merge. gates_green is the independent verification — the auditor’s submitted pass for the pull request head plus the visual gate’s release; approve_and_complete never recomputes it and refuses every merge while it is false (server/crates/sc-svc-backlog/src/backlog/complete.rs:124-127, complete.rs:216). The target repository’s required commit statuses are the second, mandatory input (complete.rs:127-130): once the policy releases a merge, backlog::merge_gate reads the required contexts — the arm’s ci_gate override, else the base branch’s protection, plus the ci_only contexts of the gate manifest (server/crates/sc-svc-backlog/src/backlog/merge_gate_inputs.rs:68-95) — and the statuses of the pull request head, records the verdict in the Merge Gate Ledger and merges only on a releasing verdict, pinned to that head (merge_gate.rs:275-291, merge_gate.rs:358-359). The forge’s commit statuses and check runs are read through the SC-1 projections in server/crates/sc-forge/src/git/ci.rs. A pending check, or an owner context such as gate-class, keeps the item in_review for the leader-leased gate watch; a failed check or a moved head blocks the item and hands it to the bounded rework loop (complete.rs:96-112). SC-5’s force_human — a diff touching a human_merge path class, a diff that cannot be classified, or an implementing profile that requires review — is checked before the policy and holds a system merge for a person under every policy, full_auto included, and at every autonomy level (complete_decision.rs:58-64, complete.rs:317-340). At autonomy level 100 the merge ceiling is full_auto (server/crates/sc-svc-tenancy/src/autonomy/policy.rs:209-210), so the project’s own merge policy decides everything that hold leaves open. The merge style is the project’s pr_conventions.merge_style, a merge commit by default (server/crates/sc-svc-backlog/src/backlog/complete_merge_pr.rs:87-95, server/crates/sc-forge/src/git/forgejo_pulls.rs:14-16). A forge that refuses that style blocks the item and tells the workspace owner which setting to change (server/crates/sc-svc-backlog/src/backlog/complete_io.rs:282-300); a transient merge failure is retried with backoff, at most ci_gate.merge_retry_max times within one hour (server/crates/sc-svc-backlog/src/backlog/merge_retry.rs:5-8).

Planned (SC-20). The Merge Gate Ledger admits a spec gate (server/migrations/417_merge_gate_ci.sql:31), and no code evaluates it yet: SupaCloud’s own spec check, as a second check beside the project’s spec gate in CI, arrives with the spec sources of section 6.

What the loop needs. The spec format is a product contract: served, versioned and drift-gated like SupaCloud’s other contracts, validated server-side as a second check, traced from requirement to evidence, and readable in the web UI.

Today. The delivery spec format 0.2 is a served contract (SC-20). spec.get serves seven contracts — openapi_public, workflow_schema, mcp_catalog, command_catalog, gate_manifest_schema, delivery_spec_schema (the current version) and delivery_spec_schema_v0_2 (pinned) (server/crates/sc-svc-mcp/src/mcp/spec_corpus.rs:24-40). The leaf crate sc-reqspec embeds the format’s JSON Schemas, imported verbatim from the reference implementation, and ports its validator and the repository rules of its spec gate (validate_repository, server/crates/sc-reqspec/src/lib.rs:1-4); the served bundle is drift-tested against the embedded schemas. The read-tier MCP tool spec.validate runs those checks on the files the caller passes (server/crates/sc-svc-mcp/src/mcp/handlers_docs.rs:100). The crate sc-spec is the workflow spec (the WorkflowSpec DTO tree).

Planned (SC-20). spec_sources, the ledger’s spec gate (off, advisory, required) and a decision_mode per project, so SupaCloud reads a project’s specs from its repository; a traceability report from requirement to evidence; drift marking of dependent items when a merged change edits a clause; a read-only spec viewer. An OpenSpec import/export adapter follows later; no runtime depends on OpenSpec tooling.

Some rules deliberately do not depend on SupaCloud:

  • The gate classes are enforced by a required status in the project’s repository, because the autonomy slider can raise SupaCloud’s merge ceiling to full_auto. SupaCloud’s merge policy may only narrow what that status allows. In the reference implementation this is built and live (gate-class, WI-SPEC-007, merged 2026-09-22), and the subsection below describes it as it runs.
  • The spec gate and the work-item gates run in the project’s own CI. SupaCloud’s spec gate is a second check, not a replacement.
  • The contracts and specs are the source of the readiness rule. SupaCloud reads them; it does not keep a second copy of work state.

The gate-class status, as it runs in the reference implementation

Section titled “The gate-class status, as it runs in the reference implementation”

The rules live in one data file (tools/qa/gate_classes.yaml, itself class G2) and one checker (tools/qa/check_gate_classes.py), documented path by path in the repository’s own gate-classes page. Each class names its approver: owner for G1 game design, G2 architecture and contracts, G3 art direction and first sight, G4 sensitive topics and G5 release and legal; security_review for S1 new dependencies, S2 CI workflows and S3 security tooling, policy and gate configuration.

What it posts. One commit status, context gate-class, on the pull request’s head commit: success when no class applies or every class that applies is cleared for exactly this head commit (the description names who cleared each), pending when a class waits, naming each class with its first path or its new package names and who is awaited, and error when no honest verdict was possible — which blocks like pending. It is a required status on the reference implementation’s main, alongside its three core-ci contexts (core-ci / python (pull_request), core-ci / format (pull_request), core-ci / dotnet (pull_request)), so a pending pull request cannot be merged by an autonomous loop or through the API by any account without admin rights.

When it runs. pull_request_target (opened, synchronize, reopened, edited), so every new head and every retarget; pull_request_review (submitted, edited); and issue_comment (created, edited, deleted) on a pull request, but only when the comment is or was an /approve-gates command. Other comments start nothing. The class map and the checker always come from the base branch — for a comment, the default branch — so a pull request cannot relax the rules it is judged by; the head is fetched only as data.

How a class is cleared.

  • An owner class is cleared by an approving review of the head commit by the owner account, or by the owner’s pull request comment /approve-gates <sha> naming that head commit (full SHA, or a prefix of at least 12 hex characters; the pending description prints the prefix to use).
  • An edited comment counts for nothing, whatever it says afterwards — any account with write access can edit anyone’s comment, so an edited body cannot be trusted to be the owner’s. Post a new comment instead. Editing or deleting one re-evaluates the pull request, which withdraws an approval that is no longer there.
  • A security-review class is cleared by an approving review of the head commit by a listed reviewer identity — the automated security review lane — or by the owner, who can always approve. A request for changes by that reviewer escalates every security-review class of the pull request to the owner, who alone clears it then.
  • An approval counts only for the commit it names. A new push is classified from scratch, dismissed and stale reviews count for nothing, and a later request for changes by the owner holds every class again, including ones a reviewer had approved.

Two honest limits. Forgejo refuses an approval by the author of a pull request, which is exactly why the owner clears their own pull requests by comment rather than by review — the comment path is a workaround for a forge rule, not an extra privilege. And an instance admin can still force-merge past branch protection whatever the rule says; that is the owner’s escape hatch, and a reason to keep instance-admin credentials away from agents. In the same spirit: any account or workflow with write access can post a commit status with any context, so the gate reliably stops the autonomous merge path — it is not a defence against a writer forging gate-class on purpose.