Skip to main content

Architecture

7review is an operator-controlled review agent. It does not treat webhooks as permission to review every change. A webhook or a manual command only creates a normalized request; policy, queue limits, SCM enrichment, context selection, model routing, validation, draft publishing, and human approval stay inside the same runtime path.

System boundaries

Boundary7review ownsExternal system
Operator controlCLI, TUI, authenticated tools, run inspectionThe human operator who decides which PR or MR should be reviewed
SCM accessNormalized request, provider routing, diff and metadata shapeGitHub or GitLab APIs and webhooks
Review executionQueue, workers, pipeline state, validation, draft outputModel providers reached through configured LLM clients
Context servicesCalls to Headroom and MemPalace clientsHeadroom and MemPalace sidecars
PublicationDraft comments, final publish command, approval stateGitHub PR or GitLab MR review surfaces

The important engineering decision is that intake is thin. HTTP handlers authenticate, normalize, apply policy, and enqueue. Workers execute the review pipeline under bounded concurrency.

Runtime map

Runtime map

Package responsibilities

PackageResponsibility
cmd/7reviewCLI entrypoint, server startup, operator commands, setup flow
agent/configEnvironment parsing for providers, queue limits, webhook policy, memory paths
agent/appHTTP routes, webhook handlers, tool execution, readiness, worker pool wiring
agent/reviewProvider-neutral domain types: request, source, diff, findings, report state
agent/pipelineReview lifecycle orchestration, deterministic gates, run store, memory interfaces
agent/toolsGitHub, GitLab, Headroom, MemPalace, tool catalog, provider routing
agent/orchestratorModel role selection, fallback behavior, role concurrency settings
agent/llmConcrete LLM clients and request/response adaptation
agent/skillsPortable review skills used as review-time context

The package split keeps provider-specific API details outside the pipeline. The pipeline should work from normalized review types, while agent/tools absorbs the differences between GitHub and GitLab.

Request lifecycle

  1. A manual command or authenticated tool call creates an exact request: github owner/repo#pr or gitlab project!mr.
  2. A webhook creates the same normalized request only when the policy gate allows automation.
  3. The app layer checks whether the run is already queued or running.
  4. The request enters the bounded worker queue.
  5. A worker enriches the request from SCM, builds source and diff context, then asks Headroom and MemPalace for the useful review context.
  6. The orchestrator routes model calls according to configured roles and fallback rules.
  7. Findings are validated before publication so malformed or stale comments are filtered deterministically.
  8. 7review publishes draft output and waits for explicit human approval before final publication and memory write.

Queue and concurrency

Webhook and manual triggers share the same queue because they produce the same kind of work. This prevents a webhook burst from bypassing the limits used by operator-triggered reviews.

SettingPurpose
WEBHOOK_WORKERSNumber of concurrent review jobs executed by the server
WEBHOOK_QUEUE_SIZEMaximum accepted backlog before new work is rejected
WEBHOOK_JOB_TIMEOUT_MSMaximum wall-clock time for one queued review job

Duplicate handling happens before enqueue. If the same provider-neutral run ID is already queued or running, the request is rejected with a clear conflict. If a previous run has completed or failed, a manual trigger can create a fresh rerun.

State model

Run data is stored under MEMORY_DIR/runs. The stored state is intentionally review-oriented rather than transport-oriented:

StateWhy it exists
Run statusLets operators distinguish queued, running, failed, completed, and approval states
Source contextKeeps the reviewed source and selected context inspectable after the run
Draft reportPreserves the model output that was prepared for publication
Inline commentsTracks confirmed line-level comments before final approval
Approval stateRecords whether final publication is still blocked by the human gate
Approved memoryWrites durable learning only after accepted review output

This is still an in-process queue. For horizontal production scaling, add a durable external queue before running multiple server instances.

Deterministic gates

The agentic part of 7review is the context selection and model review, but the runtime keeps deterministic gates around it:

  • webhook policy decides whether automation may enqueue work
  • queue capacity prevents unbounded request fan-out
  • SCM enrichment verifies the target change still exists
  • finding validation rejects comments that do not match the current diff
  • human approval blocks final publication
  • approved memory is written only after accepted review output

These gates make the service operable: the model can reason over code, while the application remains explicit about when work starts and when output becomes final.

Extension points

Add new behavior at the narrowest boundary:

ExtensionPreferred location
New SCM provideragent/tools adapter plus normalized review.Request fields
New model provideragent/llm client plus orchestrator configuration
New review gateagent/pipeline, where source, diff, and findings are available
New operator actionagent/tools catalog, then expose it through CLI or TUI
New deployment modeDocker or runtime configuration without changing pipeline semantics

The goal is to keep the review pipeline stable while changing provider, operator, or deployment surfaces independently.