Skip to content

Domain Model

Entities

Installation

Represents a GitHub App installation (one org or user account).

FieldTypeDescription
idUUIDInternal ID
githubInstallationIdnumberGitHub's installation ID
accountLoginstringGitHub org/user login
accountTypeOrganization or UserAccount type
statusInstallationStatusactive or inactive

Repository

A repository tracked by ClearPR under an installation.

FieldTypeDescription
idUUIDInternal ID
installationIdUUIDFK to Installation
githubRepoIdnumberGitHub's repo ID
fullNamestringowner/repo format
settingsJSONPer-repo config overrides
indexingStatusenumpending, in_progress, completed, failed

Review

A single review execution for a PR.

FieldTypeDescription
idUUIDInternal ID
repositoryIdUUIDFK to Repository
prNumbernumberPR number
prShastringHead commit SHA at review time
triggerenumauto, manual, rerun
statusenumqueued, processing, completed, failed, skipped
rawDiffLinesnumberTotal raw diff lines
semanticDiffLinesnumberLines after filtering
noiseReductionPctnumberPercentage of noise removed
modelUsedstringLLM model ID

PrMemoryEntry

A stored review comment with its vector embedding.

FieldTypeDescription
idUUIDInternal ID
repositoryIdUUIDFK to Repository
prNumbernumberSource PR
commentTextstringThe review comment
codeContextstringSurrounding diff hunk
outcomeenumaccepted or dismissed
embeddingvector(512)For similarity search

Value Objects

NameModulePurpose
LanguageDiff EngineFile language detection
DiffHunkDiff EngineOne contiguous block of changes
SeverityReviewcritical, warning, info
ReviewStatusReviewState machine for review lifecycle
ReviewTriggerReviewauto, manual, rerun
TokenBudgetReviewToken allocation per prompt section
FeedbackOutcomeMemoryWhether feedback was acted on
InstallationStatusGitHubActive/inactive state
WebhookEventTypeWebhookGitHub event discriminator

Domain Errors

Errors thrown by use cases or domain logic. All extend DomainError (which carries a code and an isTransient flag — transient errors trigger BullMQ retry; permanent errors do not).

ErrorModuleCodeTransient?When
GitHubApiErrorGitHubGITHUB_API_FAILEDvaries (set by status code)Any non-2xx GitHub response
GitHubRateLimitErrorGitHubGITHUB_RATE_LIMITEDyes429 / x-ratelimit-remaining: 0
LlmTimeoutErrorReviewLLM_TIMEOUTyesLLM request hits its deadline
LlmRateLimitErrorReviewLLM_RATE_LIMITEDyesLLM provider 429
MalformedLlmResponseErrorReviewLLM_RESPONSE_MALFORMEDyesLLM JSON didn't parse or fields missing
UnknownLlmProviderErrorReviewLLM_PROVIDER_UNKNOWNnoConfig has an unsupported LLM_PROVIDER value
ReviewSkippedErrorReviewREVIEW_SKIPPEDnoReview intentionally not run (e.g. diff too large)
DiffTooLargeErrorDiff EngineDIFF_TOO_LARGEnoSemantic diff exceeds MAX_DIFF_LINES; orchestrator translates to ReviewSkippedError
EmbeddingApiErrorMemoryEMBEDDING_API_FAILEDyesVoyage / embedding provider failure
InstallationNotFoundErrorMemoryINSTALLATION_NOT_FOUNDnoIndexer asked to run for an installation that's gone
InvalidRepositoryFullNameErrorMemoryINVALID_REPOSITORY_FULL_NAMEnoRepository's fullName is not owner/repo

Ports (per module)

Abstract classes used as DI tokens. Cross-module ports live in application/ports/; in-module collaborator ports live in domain/ports/.

Diff Engine

  • AstNormalizerPort (domain) — language-aware AST normalization
  • FileContentProviderPort (domain) — fetch file blobs at a given ref

Review

  • LlmProviderPort (domain) — generate review against a prompt
  • ReviewRepositoryPort (domain) — persist Review entities
  • ReviewPosterPort (domain) — post inline + summary comments
  • PrFileListProviderPort (domain) — fetch PR file list
  • DiffComputerPort (application) — cross-module port to the diff engine
  • MemoryRetrieverPort (application) — cross-module port to memory

Memory

  • EmbeddingProviderPort (domain) — text → vector
  • MemoryRepositoryPort (domain) — persist + similarity search
  • PrHistoryProviderPort (application) — cross-module port to GitHub PR history

GitHub

  • InstallationRepositoryPort (domain) — persist installations
  • RepositoryRepositoryPort (domain) — persist tracked repos

Webhook

  • IdempotencyStorePort (domain) — delivery-ID dedup store
  • JobEnqueuerPort (application) — cross-module port to the queue
  • InstallationCleanupPort (application) — cross-module port to review cleanup

Queue

  • ReviewExecutorPort (application) — cross-module port to OrchestrateReviewUseCase
  • CommandHandlerPort (application) — cross-module port to HandleCommandUseCase
  • RepositoryIndexerPort (application) — cross-module port to IndexRepositoryUseCase

Released under the MIT License.