Skip to content

Service Implementation Requirements Template

Use this template to specify the complete implementation requirements for a new Kotlin service module in the operations repository. This document bridges the feature requirements and the actual code structure.

See Implementation Best Practices for guidance on filling in each section.


Brief description of the service being specified. What domain capability does it provide? What entities does it manage?

  • Package: cards.arda.operations.<domain>.<module>
  • Repository: operations
  • Feature Requirements: Feature Name Requirements List
  • Domain Specification: Domain Specification
  • API Documentation: API Documentation

Define the business entities managed by this service using the sealed interface + Entity data class pattern.

  • Description: What this entity represents in the domain.
  • Sealed Interface: EntityName extends EntityPayload
  • Implementation: EntityName.Entity data class
  • Metadata Class: EntityNameMetadata extends ScopedMetadata or ChildMetadata
PropertyTypeRequiredDefaultDescription
eIdEntityId (UUID)YesGeneratedUnique entity identifier
nameStringYes-Description
Rule IDConditionErrorMessage
VR-001name.isBlank()AppError.ArgumentValidation”Name is required”

  • Type: enum class | sealed interface | data class
  • Package: cards.arda.operations.<domain>.<module>.domain
Value/PropertyDescription
VALUEDescription

  • Extends:
    • EditableDataAuthorityService<Entity, Metadata> (if CRUD service)
    • ObserverManager<DataAuthorityNotification<Entity, Metadata>> (if observable)
MethodSignatureDescription
createsuspend fun create(payload: E, metadata: M, time: Long, author: String, qualifier: MutationQualifier): Result<EntityRecord<E, M>>Creates a new entity
updatesuspend fun update(payload: E, metadata: M, time: Long, author: String, qualifier: MutationQualifier): Result<EntityRecord<E, M>>Updates an existing entity
deletesuspend fun delete(eId: UUID, time: Long, author: String): Result<EntityRecord<E, M>>Soft-deletes an entity
getAsOfsuspend fun getAsOf(eId: UUID, asOf: TimeCoordinates): Result<EntityRecord<E, M>?>Retrieves entity at point in time

  • Signature: suspend fun methodName(parameters): Result<ReturnType>
  • Purpose: What this method accomplishes.
ParameterTypeRequiredDescription
qualifierMutationQualifierYesMutation mode (LAX, STRICT, PROPAGATE)
timeLongYesEffective timestamp for bitemporal storage
authorStringYesIdentity of the actor performing the operation
QualifierBehavior
LAXFlexibility, minimal validation, upsert behavior
STRICTVerify consistency, fail on mismatch
PROPAGATECascade changes to related entities
EffectEntities AffectedCondition
DescriptionEntityNameWhen does this occur?
ConditionError TypeError Message
Entity not foundAppError.NotFound”Entity [id] not found”
Validation failureAppError.ArgumentValidation”field: message”
State conflictAppError.IncompatibleStateDescription

  • Table Object: TABLE_NAME extends ScopedTable
  • Record Class: EntityNameRecord extends ScopedRecord
Column NameKotlin PropertyTypeNullableDescription
e_id(inherited)uuidNoEntity identifier
tenant_id(inherited)uuidNoTenant scope
ConstraintColumnsScope
Natural identifiername, tenant_idPer-tenant unique name
  • Class: EntityNameUniverse extends ScopedUniverse
  • Purpose: Encapsulates all persistence operations for the entity
MethodDescription
create(entity, metadata, asOf, author)Insert new entity
update(entity, asOf, author, idempotency)Update existing entity
delete(eId, asOf, author)Soft-delete entity
readAsOf(eId, asOf)Read entity at point in time

  • Extension Function: Application.moduleName(cfgProvider, authentication, ...dependencies): ServiceName
Config PathTypeDescription
system.<domain>.<module>.dataSourceDataSourceConfigDatabase connection
DependencyTypePurpose
cfgProviderConfigurationProviderApplication configuration
authenticationAuthenticationAuth context

Test CategoryCoverage TargetPatterns
Entity validationAll validation rulesTest each VR-* with valid and invalid inputs
Service methodsAll MS-* specificationsMock universe, test each qualifier behavior
Error conditionsAll error scenariosVerify correct AppError types and messages
Test CategorySetupVerification
Persistence round-tripContainerizedPostgresCreate → Read → Update → Delete cycle
Transaction behaviorDatabase with test dataRollback on failure, commit on success

IDCategoryDescriptionStatus
ED-XXX-001Entity DefinitionEntityName entityProposed
VT-XXX-001Value TypeValueTypeNameProposed
SI-XXX-001Service InterfaceServiceName interfaceProposed
MS-XXX-001Method SpecmethodName methodProposed
PS-XXX-001PersistenceTableName tableProposed
PS-XXX-002PersistenceEntityNameUniverseProposed
MC-XXX-001Module ConfigModule entry pointProposed

IDQuestionOwnerStatusResolution
Q-001Question textPersonOpen/ResolvedAnswer when resolved

VersionDateAuthorChanges
1.0.0YYYY-MM-DDAuthorInitial draft