Architecture

Contracts and Versioning

This document defines the canonical contract taxonomy and semver policy for @dsar/schema.

Type taxonomy and stability

DomainContract examplesStability
RequestRequest, RequestType, RequestStatus, IntakeSource, Requestor, Authority, CapturedIntakePublic-stable
PolicyPolicyPackVersion, JurisdictionCode, RequestClock, ClockSegmentPublic-stable
VerificationVerificationLevel, VerificationCasePublic-stable
FulfillmentFulfillmentArtifact, ArtifactManifest, FulfillmentManifest, RefusalReasonCodePublic-stable
DeliveryDeliveryPackage and delivery challenge/log contractsPublic-stable
AppealsAppealPublic-stable
RetentionRetentionPolicyPublic-stable
Audit/EventAuditEvent, lifecycle transition contractsPublic-stable
Internalhelper metadata and utility schemas used to support public contractsInternal-evolving

Semver contract policy

  • Additive fields and additive enum members are minor changes.
  • Renaming or removing fields is a major change.
  • Contract behavior changes (same shape, different semantics) require migration notes and are treated as major unless explicitly backward compatible.
  • Optional metadata fields should be used when extension points are required without breaking public contracts.

Lifecycle transition contract

LifecycleTransition is the canonical transition payload and includes:

  • state movement: from, to
  • rationale: reasonCode, optional rationale
  • accountability: optional actor
  • temporal context: occurredAt
  • legal clock mutation details: optional legalClockMutation
  • approval linkage: optional approval

This contract is shared by backend runtime, audit/event pipelines, and downstream SDK/CLI workflows.

Public export map

All public symbols are exported from @dsar/schema (and mirrored via @dsar/schema/types for type-path compatibility):

  • Request contracts: RequestSchema, Request, RequestType, RequestStatus, IntakeSource, Requestor, Authority, CapturedIntake.
  • Policy/clock contracts: PolicyPackVersion, JurisdictionCode, RequestClock, ClockSegment.
  • Verification contracts: VerificationCase, VerificationLevel.
  • Fulfillment contracts: FulfillmentArtifact, ArtifactManifest, FulfillmentManifest, RefusalReasonCode.
  • Delivery contracts: DeliveryPackage and delivery challenge/log schemas.
  • Appeals contracts: Appeal.
  • Retention contracts: RetentionPolicy.
  • Audit contracts: AuditEvent, hash-chain fields (prevHash, hash, hashAlg, sequence).
  • Cross-cutting contracts: LifecycleTransition, ErrorEnvelope, ResponseMetadata.

Example payloads

Request payload (MVP intake provenance)

VerificationCase payload (MVP)

FulfillmentManifest payload (MVP)