Source Tree Analysis
Annotated directory structure and critical file reference for the Slop codebase.
Repository Root
The top-level layout separates source code, data, configuration, test infrastructure, and the harness that gets deployed to watched repos.
src/app/
Next.js 16 App Router. Pages, layouts, React components, Server Actions, and REST API routes all live here. The root route (/) is the Kanban board.
src/db/
One repo file per Prisma model concern. Repository functions are pure Prisma passthroughs — no try/catch, no business logic. Each ships with a paired .test.ts against the real SQLite test DB.
src/lib/
Shared utilities with no circular dependencies. Pure functions; no DB access; no daemon imports. Organized into subdirectories by concern.
src/server/daemon/
The daemon is a Node.js singleton that runs the poll cycle, manages worker lifecycles, and owns all state mutations. It boots once per server process and is accessed by Server Actions via getRunningDaemon().
src/server/workers/
The per-issue worker pipeline. Each worker is a long-running async function that progresses through phases: implement, verify, CI-fix, conflict resolution, PR review, and address-comments. All collaborators are injected via the RunWorkerDeps / Deps object.
src/server/github/
Thin REST wrapper around the GitHub API. All callers receive the client through dependency injection — from-env.ts constructs the real client; tests use fake.ts.
src/server/runs/
Skill run orchestration — separate from the per-issue worker pipeline. Handles standalone agent invocations: suggesting story points, generating worker reports, running doc-editing skills, and PR review automation.
src/types/
Shared TypeScript types that cross module boundaries. No runtime code — pure type declarations. Consumers import from @/types/<feature>.
src/types/.
prisma/
SQLite via Prisma ORM. The schema defines all models. Migrations are checked in and run sequentially — never edited after creation. Use pnpm exec tsx scripts/prisma-migrate-dev.ts to create a new migration (this script backs up the DB first).
data/slop_test.db is reset between test runs by vitest.global-setup.ts via prisma db push --accept-data-loss. Never run migrations against the test DB manually.
Critical Files
The 25 files most likely to be the right edit target for any given task. When in doubt, start here.
| File | Purpose |
|---|---|
src/server/daemon/index.ts | Daemon singleton implementation — the central coordinator for all background work |
src/server/daemon/types.ts | Daemon interface contract — add new operations here first |
src/server/daemon/tick.ts | 13-step poll cycle — controls what happens every N seconds |
src/server/daemon/claim-worker.ts | Next-issue selection logic with concurrency cap enforcement |
src/server/daemon/lifecycle-poll.ts | GitHub reconciliation — detects external PR merges and closures |
src/server/workers/worker.ts | Worker entry point — timeout, abort signal, top-level error handler |
src/server/workers/lifecycle.ts | Status state machine — all valid transitions and CAS writes |
src/server/workers/phase-runner.ts | Phase loop — decides which phases to run and in what order |
src/server/workers/run-impl.ts | Implementation phase — Claude Code invocation construction |
src/server/workers/shipping.ts | PR creation, auto-merge, and post-merge cleanup |
src/server/workers/agent.ts | Claude Code subprocess spawn and event streaming |
src/server/workers/git.ts | All git operations used by the worker pipeline |
src/server/workers/worktree.ts | Worktree lifecycle — nested at WORKTREES_ROOT/repoId/issueNumber |
src/server/github/client.ts | GitHub REST client — all external API calls |
src/app/actions/_shared.ts | getRunningDaemon(), ActionResult type, shared action utilities |
src/app/actions/worker.ts | Worker Server Actions — startWorker through clearFinishedWorkers |
src/app/actions/issue.ts | Issue lifecycle Server Actions — setIssueReady, startIssue, reorder |
src/app/api/events/route.ts | SSE stream route — board live updates |
src/db/worker.repo.ts | Worker table access — most-read repo in the codebase |
src/db/config.repo.ts | Global config access — read on every tick |
src/db/ready-issue.repo.ts | Ready queue membership — claim-worker reads this on every cycle |
src/lib/agent/agent-model.ts | Model + effort level resolution — controls which Claude model is used |
src/middleware.ts | Auth enforcement for all routes — guards the API and UI pages |
prisma/schema.prisma | Single source of truth for the data model |
docs/surface-map.md | Signatures-only index of all edit seams — start here when locating code |
Migration History
40 migrations tracing the feature evolution from initial schema to the current state. Each directory contains a single migration.sql.
| Timestamp | Migration name |
|---|---|
| 20260528_130143 | init |
| 20260528_132733 | add_worker_issue_title_url |
| 20260528_160312 | add_worker_status_index |
| 20260528_204649 | add_worker_notified_at |
| Timestamp | Migration name |
|---|---|
| 20260529_150000 | add_worker_report_and_repo_snapshot |
| 20260529_152241 | add_issue_chat |
| 20260530_055239 | add_event_level |
| 20260601_014236 | add_event_raw_content |
| Timestamp | Migration name |
|---|---|
| 20260602_002512 | add_worker_session_resume |
| 20260603_193518 | add_worker_verification_attempts |
| 20260604_011226 | per_issue_overrides |
| 20260604_030924 | issue_config |
| 20260605_160655 | per_issue_review_overrides |
| 20260605_224613 | ready_issue_drop_graph |
| 20260606_012934 | add_waiting_merge_tracking |
| 20260606_133631 | add_status_before_report |
| Timestamp | Migration name |
|---|---|
| 20260607_182149 | add_points_auto_scored |
| 20260607_190000 | add_run_agent_metadata |
| 20260607_193000 | multi_repo |
| 20260608_000000 | drop_issue_chat |
| 20260608_120000 | add_worker_issue_source |
| 20260608_130000 | surface_internal_issues_in_kanban |
| 20260608_194400 | restart_sync |
| Timestamp | Migration name |
|---|---|
| 20260608_113958 | add_internal_issue_store |
| 20260609_211213 | add_label |
| 20260610_000000 | remove_invalid_labels |
| 20260610_151643 | add_run_report |
| 20260611_033823 | restart_sync |
| 20260611_034335 | add_session_harness |
| 20260611_050522 | plan_artifacts |
| 20260611_060000 | add_run_repo_id |
| 20260611_120000 | story_ordering_epic_hierarchy_schema |
| 20260611_143010 | story_ordering_epic_hierarchy_schema (rev) |
| 20260611_221719 | graph_feature |
| 20260611_234441 | drop_plan |
| Timestamp | Migration name |
|---|---|
| 20260612_012331 | add_batch |
| 20260612_020806 | add_repo_parallelism_cap |
| 20260612_045905 | add_kind_to_worker |
| 20260612_050000 | add_internal_issue_id_to_worker |
| 20260612_084201 | add_status_before_pause |