Skip to content

cold-start: split regression execution into executor module#42

Merged
x0ba merged 1 commit into
stagingfrom
cold-start/split-regression-executor
May 28, 2026
Merged

cold-start: split regression execution into executor module#42
x0ba merged 1 commit into
stagingfrom
cold-start/split-regression-executor

Conversation

@x0ba
Copy link
Copy Markdown
Owner

@x0ba x0ba commented May 28, 2026

Stack Context

This stack reduces Vercel cold-start time by shrinking the shared SvelteKit server boot path and isolating heavy agent/GitHub dependencies.

Why?

regression/runs.ts statically imported the agent runner, so webhook and regression CRUD routes bundled Playwright even when no agent work ran. Execution moves to executor.ts with dynamic agent-runner imports when a case actually starts.

Test plan

  • Trigger a regression suite run from the dashboard
  • Confirm GitHub webhook-triggered regression runs still schedule and execute

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flightlog Ready Ready Preview, Comment May 28, 2026 4:51pm

Copy link
Copy Markdown
Owner Author

x0ba commented May 28, 2026

@x0ba x0ba changed the title Move regression run execution into a dedicated executor module. cold-start: split regression execution into executor module May 28, 2026
@x0ba x0ba marked this pull request as ready for review May 28, 2026 07:56
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Greptile Summary

This PR refactors regression execution by extracting scheduleRegressionRun and executeRegressionRun from runs.ts into a new executor.ts module, dynamically importing createAgentRun/maybeStartAgentRun (the Playwright-heavy path) only when a case actually starts. Both webhooks.ts and the suite-runs API route now import scheduleRegressionRun from executor instead of runs.

  • Bundle improvement: createAgentRun and maybeStartAgentRun are now dynamic imports inside executeRegressionCase, so webhook and CRUD routes no longer pull Playwright into their static bundle.
  • updateRegressionCheckRun (GitHub) was already a dynamic import in the old code and remains so.
  • evaluateRun and findRun remain as static imports in executor.ts; since both webhooks.ts and +server.ts now statically import executor, these modules are still bundled on those routes — the refactor is a meaningful but partial cold-start win.

Confidence Score: 5/5

Safe to merge — the change is a clean mechanical extraction with no logic modifications.

The extraction faithfully mirrors the old logic from runs.ts into executor.ts without altering any business rules. The dynamic imports for createAgentRun and maybeStartAgentRun are the only behavioural change and they improve, not regress, the situation. The concerns previously raised (in-memory dedup across serverless instances, remaining static imports of evaluateRun/findRun) were flagged in earlier review rounds and are not introduced by this PR.

No files require special attention; executor.ts is the only new file and its logic is a direct lift from the prior runs.ts.

Important Files Changed

Filename Overview
src/lib/server/regression/executor.ts New module extracting scheduleRegressionRun/executeRegressionRun from runs.ts; correctly dynamic-imports agent-runner and github/checks, but still statically imports evaluateRun and findRun (noted in prior review).
src/lib/server/regression/runs.ts Execution logic removed cleanly; remaining static imports of evaluateRun and findRun are legitimately used by completeRegressionCaseRun.
src/lib/server/github/webhooks.ts Import of scheduleRegressionRun moved from runs to executor; no logic changes.
src/routes/api/regression/suites/[id]/runs/+server.ts Import of scheduleRegressionRun moved from runs to executor; no logic changes.

Sequence Diagram

sequenceDiagram
    participant WH as webhooks.ts
    participant API as +server.ts (POST)
    participant Runs as regression/runs.ts
    participant Exec as regression/executor.ts
    participant DB as Database
    participant Agent as agent-runner/service (dynamic)
    participant GH as github/checks (dynamic)

    WH->>Runs: createRegressionRunForRepository()
    Runs->>DB: insert regressionRun + caseRuns
    Runs-->>WH: "{ regressionRun, suite }"
    WH->>Exec: scheduleRegressionRun(id)

    API->>Runs: createRegressionRun()
    Runs->>DB: insert regressionRun + caseRuns
    Runs-->>API: regressionRun
    API->>Exec: scheduleRegressionRun(id)
    API-->>API: return 201 (fire-and-forget)

    Note over Exec: void executeRegressionRun() async
    Exec->>DB: fetch regressionRun + caseRuns
    Exec->>DB: "set status = 'running'"
    loop For each pending caseRun
        Exec->>DB: "set caseRun status = 'running'"
        Exec->>Agent: await import() createAgentRun + maybeStartAgentRun
        Exec->>Exec: waitForRunCompletion (poll 2s, max 10min)
        Exec->>Exec: evaluateRun() [static import]
        Exec->>DB: update caseRun (success/failed)
        Exec->>GH: await import() updateRegressionCheckRun
    end
    Exec->>DB: aggregateSuiteResult update regressionRun
    Exec->>GH: updateRegressionCheckRun (final)
Loading

Reviews (2): Last reviewed commit: "Move regression run execution into a ded..." | Re-trigger Greptile

Comment thread src/lib/server/regression/executor.ts
Comment thread src/lib/server/regression/executor.ts
Copy link
Copy Markdown
Owner Author

x0ba commented May 28, 2026

Merge activity

  • May 28, 4:49 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 28, 4:51 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 28, 4:51 PM UTC: @x0ba merged this pull request with Graphite.

@x0ba x0ba changed the base branch from cold-start/decouple-webhook-hooks to graphite-base/42 May 28, 2026 16:49
@x0ba x0ba changed the base branch from graphite-base/42 to staging May 28, 2026 16:49
Agent runner imports are deferred until a regression case actually runs, keeping Playwright out of webhook and regression CRUD bundles.
@x0ba x0ba force-pushed the cold-start/split-regression-executor branch from 555a83c to 2a72555 Compare May 28, 2026 16:50
@x0ba x0ba merged commit 2d27b93 into staging May 28, 2026
3 of 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.

1 participant