Skip to content

fix(api): preflight missing repository before builder dispatch - #168

Open
elirethDev wants to merge 2 commits into
theam:mainfrom
elirethDev:fix/checks-configured-dispatch-gate
Open

fix(api): preflight missing repository before builder dispatch#168
elirethDev wants to merge 2 commits into
theam:mainfrom
elirethDev:fix/checks-configured-dispatch-gate

Conversation

@elirethDev

@elirethDev elirethDev commented Aug 16, 2026

Copy link
Copy Markdown

Related to #28.

What changes

A builder run without a repository cannot create a branch or pull request. Before this change, it could provision the sandbox and spend the run budget before the runner reported delivery_repo_not_configured.

  • dispatchRun now fails a builder without a repository before the atomic claim, spend-capable key creation, or sandbox provisioning, using delivery_repo_not_configured.
  • Connected GitHub repository triggers no longer run an API-side check-command preflight. Under the current contract, GitHub CI owns acceptance for those deliveries.
  • The session page renders delivery_repo_not_configured as a human explanation with a link to project Settings. Unknown errors still render raw, and the existing checks_not_configured presentation remains available as a runner backstop.

The connected-repository/no-kickstart scenario described in #28 appears to have been superseded by the current GitHub-CI-owned acceptance model. The repo-connect prompt from the original issue remains outside this change.

Files

File Change
services/api/src/sandbox/delivery-gate.ts Delivery-mode and repository preflight predicate
services/api/src/sandbox/orchestrator.ts Fail repo-less builders before claim, key creation, or provisioning
services/api/src/routes/v1/github.ts, services/api/src/github/router.ts Remove the obsolete check-command trigger preflights
apps/web/components/run/run-error.ts Human-readable delivery_repo_not_configured presentation
services/api/test/*, apps/web/test/run-error.test.ts Regression coverage for repo-less builders and connected GitHub repositories

Verification

  • API focused tests: 90 passed, 1 timing-based timeout in github-platform-lane.test.ts (coalesces a CI notification burst), 0 skipped; the database-backed suites ran with Docker/Postgres healthy
  • Web error presentation test: 8/8 passed
  • pnpm --filter @facility/api typecheck and pnpm --filter @facility/web typecheck: pass
  • pnpm exec biome check on the changed files: clean
  • git diff HEAD^ HEAD --check: clean
  • Full pnpm verify remains blocked at its first Lint step by the existing Windows scripts/verify.mjs spawnSync("pnpm") issue (ENOENT); the full acceptance suite remains for CI.

…nce checks are configured

A delivery-mode run without acceptance checks (check_cmds empty) and without a
GitHub-backed repo used to provision a full sandbox, spend the budget on the
agent run, and only then fail at the runner's delivery gate with
checks_not_configured — no branch, no PR, work discarded.

- dispatchRun now evaluates the runner's acceptance gate up front (mirrored
  from runner/src/index.ts: requiresDelivery + githubCiOwnsAcceptance): the run
  fails immediately with checks_not_configured before any sandbox or
  spend-capable key exists.
- web issue trigger and slash-command routing refuse to insert the run (409 /
  routed:false) under the same predicate, resolving check commands with the
  buildRunBundle precedence (profile override, repo render answers, project
  settings).
- the session page renders the checks_not_configured JSON failure as a human
  explanation with a link to the project settings gates editor via a small
  tested error-code mapping helper; unknown errors still render raw.

Per the runner's semantics, GitHub-backed repos remain exempt: their CI owns
acceptance of the signed draft PR.
// owns acceptance.
export function checksConfiguredForDispatch(bundle: AcceptanceBundle): boolean {
return (
githubCiOwnsAcceptance(bundle) || !requiresDelivery(bundle.mode) || bundle.checkCmds.length > 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn’t seem to catch the case from #28 anymore. checksConfiguredForRepo() gives every connected repo a GitHub URL, so this always passes for a builder even when checkCmds is empty. The only builder it blocks has no repo; asking that user to configure checks is misleading, because the run will then start and fail with delivery_repo_not_configured. Could we either preflight the missing repo too, or re-scope this now that GitHub CI owns acceptance?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Mmm, yeah, you're right. Looking at the current flow, I think the right thing to do is:

  • replace the current API-side checks preflight with an early delivery_repo_not_configured guard for builder runs without a repository, before creating keys or provisioning a sandbox;
  • remove the checksConfiguredForRepo() preflight from connected GitHub repository triggers;
  • add human-readable UI copy and regression tests for that failure mode;
  • update the PR description to make it clear that GitHub CI owns acceptance for connected repositories.

That way, connected repositories follow the current GitHub CI acceptance model, while builder runs without a repository fail early instead of spending resources on a run that cannot deliver.

@elirethDev elirethDev Aug 17, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Implemented in 19d5d88.

Connected GitHub repositories no longer run the check-command preflight. Builder runs without a repository now fail before key creation or sandbox provisioning with delivery_repo_not_configured, with matching UI copy and regression coverage. I also updated the PR title and description to reflect the current GitHub CI acceptance model.

Focused checks pass: 32 API tests, 8 web tests, both typechecks, Biome, and diff whitespace checks.

@elirethDev elirethDev Aug 17, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I reran the database-backed suites with Docker and Postgres healthy. The result was 90 passed, 1 timing-based timeout in coalesces a CI notification burst, and no skipped tests.

I also confirmed that pnpm verify still stops at its first Lint step on Windows with scripts/verify.mjs calling spawnSync("pnpm") and receiving ENOENT.

@elirethDev elirethDev changed the title fix(api): refuse builder dispatch before provisioning when no acceptance checks are configured fix(api): preflight missing repository before builder dispatch Aug 17, 2026
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