packages feed

hydra-build-0.17.3: src/main/haskell/Hydra/Build/Format.hs

-- Note: this is an automatically generated file. Do not edit.

-- | Type-level specifications of the JSON formats used by Hydra's build system: the repository descriptor (hydra.json), per-package descriptors (package.json), per-source-set input and output digests (digest.json), generated-source manifests (manifest.json), and per-package validation configuration. Each on-disk file is the canonical JSON encoding of the corresponding type. Overlay build configuration (overlay/<lang>/<pkg>/build.json) is specified separately, by hydra.gradle and hydra.python.pyproject. See https://github.com/CategoricalData/hydra/issues/512

module Hydra.Build.Format where

import qualified Hydra.Core as Core
import qualified Hydra.Packaging as Packaging
import Prelude hiding  (Enum, Ordering, decodeFloat, encodeFloat, fail, map, pure, sum)
import qualified Data.Scientific as Sci
import qualified Data.Map as M

-- | Configuration for the definition-name-convention check
data DefinitionNameConventionProfile =
  DefinitionNameConventionProfile {
    -- | How a finding of this check is treated
    definitionNameConventionProfileSeverity :: Severity,
    -- | Whether underscores are permitted in definition names
    definitionNameConventionProfileAllowUnderscores :: Bool}
  deriving (Eq, Ord, Read, Show)

_DefinitionNameConventionProfile = Core.Name "hydra.build.format.DefinitionNameConventionProfile"

_DefinitionNameConventionProfile_severity = Core.Name "severity"

_DefinitionNameConventionProfile_allowUnderscores = Core.Name "allowUnderscores"

-- | Validation rules applying to individual definitions within a module. Absent fields mean the corresponding check is not configured.
data DefinitionValidationProfile =
  DefinitionValidationProfile {
    -- | Configuration for the definition-documentation check
    definitionValidationProfileHasDescription :: (Maybe DocumentationProfile),
    -- | Whether definitions must appear in alphabetical order
    definitionValidationProfileOrdering :: (Maybe Severity),
    -- | Configuration for the definition-name-convention check
    definitionValidationProfileNameConvention :: (Maybe DefinitionNameConventionProfile),
    -- | Whether a definition name may duplicate part of its module name
    definitionValidationProfileNotInModuleName :: (Maybe Severity),
    -- | Whether duplicate definition names within a module are reported
    definitionValidationProfileDuplicateName :: (Maybe Severity)}
  deriving (Eq, Ord, Read, Show)

_DefinitionValidationProfile = Core.Name "hydra.build.format.DefinitionValidationProfile"

_DefinitionValidationProfile_hasDescription = Core.Name "hasDescription"

_DefinitionValidationProfile_ordering = Core.Name "ordering"

_DefinitionValidationProfile_nameConvention = Core.Name "nameConvention"

_DefinitionValidationProfile_notInModuleName = Core.Name "notInModuleName"

_DefinitionValidationProfile_duplicateName = Core.Name "duplicateName"

-- | One file's classification and content hash within a digest
data DigestEntry =
  DigestEntry {
    -- | The kind of artifact recorded
    digestEntryKind :: DigestKind,
    -- | The SHA-256 hash of the file content
    digestEntryHash :: Sha256Hash}
  deriving (Eq, Ord, Read, Show)

_DigestEntry = Core.Name "hydra.build.format.DigestEntry"

_DigestEntry_kind = Core.Name "kind"

_DigestEntry_hash = Core.Name "hash"

-- | The kind of artifact recorded in a digest entry. Lets a single digest mix typed entries without losing the discriminator.
data DigestKind =
  -- | A DSL source file under a package's src/main source tree
  DigestKindDslSource |
  -- | A JSON file under dist/json/
  DigestKindJsonFile |
  -- | A generated source file under dist/<lang>/
  DigestKindTargetFile |
  -- | A hand-written runtime support file copied into the distribution
  DigestKindRuntimeFile |
  -- | Anything else (escape hatch; unknown kinds round-trip as this variant)
  DigestKindOther
  deriving (Eq, Ord, Read, Show)

_DigestKind = Core.Name "hydra.build.format.DigestKind"

_DigestKind_dslSource = Core.Name "dslSource"

_DigestKind_jsonFile = Core.Name "jsonFile"

_DigestKind_targetFile = Core.Name "targetFile"

_DigestKind_runtimeFile = Core.Name "runtimeFile"

_DigestKind_other = Core.Name "other"

-- | Configuration for the definition-documentation check
data DocumentationProfile =
  DocumentationProfile {
    -- | How a finding of this check is treated
    documentationProfileSeverity :: Severity,
    -- | Whether deprecated definitions are exempt from the documentation requirement
    documentationProfileExemptDeprecated :: Bool}
  deriving (Eq, Ord, Read, Show)

_DocumentationProfile = Core.Name "hydra.build.format.DocumentationProfile"

_DocumentationProfile_severity = Core.Name "severity"

_DocumentationProfile_exemptDeprecated = Core.Name "exemptDeprecated"

-- | A structured generation-provenance record for generated artifacts, separating gating identity from informational provenance. Only generatorId gates cache freshness; it is host-independent by design, since self-hosting requires every host to produce byte-identical output. All other fields are informational and must not gate. Invariant: a shim-mode generation has a revision (a shim has no release version, so the working-tree revision is its only precise identity).
data Generation =
  Generation {
    -- | The gating cache key identifying the generator that produced the outputs
    generationGeneratorId :: String,
    -- | Whether the artifact was produced by a published host or a locally-built migration shim
    generationMode :: GenerationMode,
    -- | The producing host language (informational)
    generationHost :: LanguageName,
    -- | The release version of the producing host (informational; omitted for shim builds)
    generationHydraVersion :: (Maybe Packaging.Version),
    -- | The producing worktree's revision, as <short-sha> with "-dirty" appended when the tree has uncommitted changes (informational; required for shim builds)
    generationRevision :: (Maybe String),
    -- | The ISO-8601 UTC time of generation (informational; non-deterministic across byte-identical rebuilds)
    generationTimestamp :: (Maybe String)}
  deriving (Eq, Ord, Read, Show)

_Generation = Core.Name "hydra.build.format.Generation"

_Generation_generatorId = Core.Name "generatorId"

_Generation_mode = Core.Name "mode"

_Generation_host = Core.Name "host"

_Generation_hydraVersion = Core.Name "hydraVersion"

_Generation_revision = Core.Name "revision"

_Generation_timestamp = Core.Name "timestamp"

-- | The provenance class of a generated artifact
data GenerationMode =
  -- | Produced by a published, versioned host
  GenerationModePublished |
  -- | Produced by a locally-built migration shim, ahead of any published host
  GenerationModeShim
  deriving (Eq, Ord, Read, Show)

_GenerationMode = Core.Name "hydra.build.format.GenerationMode"

_GenerationMode_published = Core.Name "published"

_GenerationMode_shim = Core.Name "shim"

-- | An override of the default published-host consumption for one host language: either force a local from-source build, or pin a specific published version.
data HostOverride =
  -- | Build and consume the host locally from source rather than from the package registry
  HostOverrideLocal |
  -- | Pin the host to a specific published version
  HostOverrideVersion Packaging.Version
  deriving (Eq, Ord, Read, Show)

_HostOverride = Core.Name "hydra.build.format.HostOverride"

_HostOverride_local = Core.Name "local"

_HostOverride_version = Core.Name "version"

-- | A per-package, per-source-set input digest (dist/json/<pkg>/build/<set>/digest.json): Merkle-style hashes of the package's DSL sources, recorded when the package's JSON is written and consumed by downstream freshness checks. The selfHash summarizes the package's own module hashes; dependencyHashes captures the selfHash of each declared dependency package at write time, giving transitive invalidation.
data InputDigest =
  InputDigest {
    -- | The version of this digest file's own schema
    inputDigestDigestFormatVersion :: Int,
    -- | The version of the JSON encoding of the sibling module files
    inputDigestModuleFormatVersion :: Int,
    -- | A deterministic hash over all of the package's per-module hashes (absent in legacy digests)
    inputDigestSelfHash :: (Maybe Sha256Hash),
    -- | For each declared dependency package, that package's selfHash as recorded at write time
    inputDigestDependencyHashes :: (M.Map Packaging.PackageName Sha256Hash),
    -- | The hash of each module's source, keyed by module name
    inputDigestModuleHashes :: (M.Map Packaging.ModuleName Sha256Hash)}
  deriving (Eq, Ord, Read, Show)

_InputDigest = Core.Name "hydra.build.format.InputDigest"

_InputDigest_digestFormatVersion = Core.Name "digestFormatVersion"

_InputDigest_moduleFormatVersion = Core.Name "moduleFormatVersion"

_InputDigest_selfHash = Core.Name "selfHash"

_InputDigest_dependencyHashes = Core.Name "dependencyHashes"

_InputDigest_moduleHashes = Core.Name "moduleHashes"

-- | The name of a source or target language in Hydra's build system, e.g. "haskell", "java", or "python"
newtype LanguageName =
  LanguageName {
    unLanguageName :: String}
  deriving (Eq, Ord, Read, Show)

_LanguageName = Core.Name "hydra.build.format.LanguageName"

-- | Validation rules applying to a module as a whole. Absent fields mean the corresponding check is not configured.
data ModuleValidationProfile =
  ModuleValidationProfile {
    -- | Validation rules applying to the module's individual definitions
    moduleValidationProfileDefinitions :: (Maybe DefinitionValidationProfile),
    -- | Whether module names must follow naming conventions
    moduleValidationProfileNameConvention :: (Maybe Severity),
    -- | Whether union variant names conflicting across the module are reported
    moduleValidationProfileConflictingVariantName :: (Maybe Severity)}
  deriving (Eq, Ord, Read, Show)

_ModuleValidationProfile = Core.Name "hydra.build.format.ModuleValidationProfile"

_ModuleValidationProfile_definitions = Core.Name "definitions"

_ModuleValidationProfile_nameConvention = Core.Name "nameConvention"

_ModuleValidationProfile_conflictingVariantName = Core.Name "conflictingVariantName"

-- | A per-package, per-source-set output digest for one target language (dist/<lang>/<pkg>/build/<set>/digest.json), recording every input file whose content determines the generated output, every output file the generation step is responsible for, and the identity of the generator. A generation step is fresh exactly when all input hashes, all output hashes, the generator identity, and the recorded package and dependency hashes match.
data OutputDigest =
  OutputDigest {
    -- | The version of this digest file's own schema
    outputDigestDigestFormatVersion :: Int,
    -- | The version of the JSON encoding of the module files this digest governs
    outputDigestModuleFormatVersion :: Int,
    -- | The flat gating generator identity (a compatibility duplicate of generation.generatorId)
    outputDigestGenerator :: String,
    -- | The structured generation-provenance record
    outputDigestGeneration :: Generation,
    -- | The input package's selfHash as recorded at refresh time (absent in legacy digests)
    outputDigestSelfHash :: (Maybe Sha256Hash),
    -- | For each declared dependency package, that package's selfHash as recorded at refresh time
    outputDigestDependencyHashes :: (M.Map Packaging.PackageName Sha256Hash),
    -- | Every input file's kind and hash, keyed by worktree-relative path
    outputDigestInputs :: (M.Map String DigestEntry),
    -- | Every output file's kind and hash, keyed by path relative to the output directory
    outputDigestOutputs :: (M.Map String DigestEntry)}
  deriving (Eq, Ord, Read, Show)

_OutputDigest = Core.Name "hydra.build.format.OutputDigest"

_OutputDigest_digestFormatVersion = Core.Name "digestFormatVersion"

_OutputDigest_moduleFormatVersion = Core.Name "moduleFormatVersion"

_OutputDigest_generator = Core.Name "generator"

_OutputDigest_generation = Core.Name "generation"

_OutputDigest_selfHash = Core.Name "selfHash"

_OutputDigest_dependencyHashes = Core.Name "dependencyHashes"

_OutputDigest_inputs = Core.Name "inputs"

_OutputDigest_outputs = Core.Name "outputs"

-- | A package descriptor (packages/<pkg>/package.json): the source-of-truth declaration of a Hydra package's name, source language, dependencies, and optional per-package configuration.
data PackageDescriptor =
  PackageDescriptor {
    -- | The version of this descriptor file's schema
    packageDescriptorPackageFormatVersion :: Int,
    -- | The unique name of the package, e.g. "hydra-kernel"
    packageDescriptorName :: Packaging.PackageName,
    -- | A concise human-readable summary of the package
    packageDescriptorDescription :: String,
    -- | The language in which the package's DSL sources are authored
    packageDescriptorSourceLanguage :: LanguageName,
    -- | The target languages for which distributions of this package are generated. When absent, the default target set applies.
    packageDescriptorTargetLanguages :: (Maybe [LanguageName]),
    -- | The names of the packages this package depends upon
    packageDescriptorDependencies :: [Packaging.PackageName],
    -- | Optional per-package validation configuration. When absent, the validation engine's defaults apply.
    packageDescriptorValidation :: (Maybe PackageValidationConfiguration)}
  deriving (Eq, Ord, Read, Show)

_PackageDescriptor = Core.Name "hydra.build.format.PackageDescriptor"

_PackageDescriptor_packageFormatVersion = Core.Name "packageFormatVersion"

_PackageDescriptor_name = Core.Name "name"

_PackageDescriptor_description = Core.Name "description"

_PackageDescriptor_sourceLanguage = Core.Name "sourceLanguage"

_PackageDescriptor_targetLanguages = Core.Name "targetLanguages"

_PackageDescriptor_dependencies = Core.Name "dependencies"

_PackageDescriptor_validation = Core.Name "validation"

-- | A generated-source manifest (dist/<lang>/<pkg>/src/<set>/<lang>/manifest.json): the list of modules generated into a distribution package, partitioned by role.
data PackageManifest =
  PackageManifest {
    -- | The version of this manifest file's schema
    packageManifestManifestFormatVersion :: Int,
    -- | The version of the JSON encoding of the sibling module files
    packageManifestModuleFormatVersion :: Int,
    -- | The name of the package this manifest describes
    packageManifestPackage :: Packaging.PackageName,
    -- | All main-source-set modules in the package
    packageManifestMainModules :: [Packaging.ModuleName],
    -- | All test-source-set modules in the package
    packageManifestTestModules :: [Packaging.ModuleName],
    -- | The subset of main modules which define type schemas and give rise to generated DSL wrapper modules
    packageManifestMainDslModules :: [Packaging.ModuleName],
    -- | The subset of main modules for which encoding and decoding modules are generated
    packageManifestMainEncodingModules :: [Packaging.ModuleName]}
  deriving (Eq, Ord, Read, Show)

_PackageManifest = Core.Name "hydra.build.format.PackageManifest"

_PackageManifest_manifestFormatVersion = Core.Name "manifestFormatVersion"

_PackageManifest_moduleFormatVersion = Core.Name "moduleFormatVersion"

_PackageManifest_package = Core.Name "package"

_PackageManifest_mainModules = Core.Name "mainModules"

_PackageManifest_testModules = Core.Name "testModules"

_PackageManifest_mainDslModules = Core.Name "mainDslModules"

_PackageManifest_mainEncodingModules = Core.Name "mainEncodingModules"

-- | The full, opt-in validation configuration for a package, as declared in its package descriptor. Every field cascades optional; an absent field means the corresponding rule family is not configured and the validation engine's defaults apply.
data PackageValidationConfiguration =
  PackageValidationConfiguration {
    -- | Validation rules applying to the package as a whole
    packageValidationConfigurationPackage :: (Maybe PackageValidationProfile),
    -- | Validation rules applying to each module
    packageValidationConfigurationModule :: (Maybe ModuleValidationProfile),
    -- | Validation rules applying to type-definition bodies
    packageValidationConfigurationType :: (Maybe TypeValidationProfile),
    -- | Validation rules applying to term-definition bodies
    packageValidationConfigurationTerm :: (Maybe TermValidationProfile)}
  deriving (Eq, Ord, Read, Show)

_PackageValidationConfiguration = Core.Name "hydra.build.format.PackageValidationConfiguration"

_PackageValidationConfiguration_package = Core.Name "package"

_PackageValidationConfiguration_module = Core.Name "module"

_PackageValidationConfiguration_type = Core.Name "type"

_PackageValidationConfiguration_term = Core.Name "term"

-- | Validation rules applying to a package as a whole. Absent fields mean the corresponding check is not configured.
data PackageValidationProfile =
  PackageValidationProfile {
    -- | Whether module names conflicting across the package are reported
    packageValidationProfileConflictingModuleName :: (Maybe Severity),
    -- | Whether duplicate module names within the package are reported
    packageValidationProfileDuplicateModuleName :: (Maybe Severity),
    -- | Whether package names must follow naming conventions
    packageValidationProfileNameConvention :: (Maybe Severity)}
  deriving (Eq, Ord, Read, Show)

_PackageValidationProfile = Core.Name "hydra.build.format.PackageValidationProfile"

_PackageValidationProfile_conflictingModuleName = Core.Name "conflictingModuleName"

_PackageValidationProfile_duplicateModuleName = Core.Name "duplicateModuleName"

_PackageValidationProfile_nameConvention = Core.Name "nameConvention"

-- | The repository descriptor (hydra.json at the repository root): release and host versions, host consumption overrides, publication metadata, and the list of source packages.
data RepositoryDescriptor =
  RepositoryDescriptor {
    -- | The version currently under development
    repositoryDescriptorCurrentVersion :: Packaging.Version,
    -- | The published host version consumed by default when generating code
    repositoryDescriptorHostVersion :: Packaging.Version,
    -- | Per-host-language overrides of the default published-host consumption
    repositoryDescriptorHostOverrides :: (M.Map LanguageName HostOverride),
    -- | The group identifier under which artifacts are published, e.g. a Maven group id
    repositoryDescriptorGroup :: String,
    -- | The author attribution for published artifacts
    repositoryDescriptorAuthor :: String,
    -- | The URL of the project
    repositoryDescriptorUrl :: String,
    -- | The license identifier for published artifacts, e.g. "Apache-2.0"
    repositoryDescriptorLicense :: String,
    -- | The names of the repository's source packages
    repositoryDescriptorPackages :: [Packaging.PackageName]}
  deriving (Eq, Ord, Read, Show)

_RepositoryDescriptor = Core.Name "hydra.build.format.RepositoryDescriptor"

_RepositoryDescriptor_currentVersion = Core.Name "currentVersion"

_RepositoryDescriptor_hostVersion = Core.Name "hostVersion"

_RepositoryDescriptor_hostOverrides = Core.Name "hostOverrides"

_RepositoryDescriptor_group = Core.Name "group"

_RepositoryDescriptor_author = Core.Name "author"

_RepositoryDescriptor_url = Core.Name "url"

_RepositoryDescriptor_license = Core.Name "license"

_RepositoryDescriptor_packages = Core.Name "packages"

-- | How a validation finding is treated
data Severity =
  SeverityError |
  SeverityWarning
  deriving (Eq, Ord, Read, Show)

_Severity = Core.Name "hydra.build.format.Severity"

_Severity_error = Core.Name "error"

_Severity_warning = Core.Name "warning"

-- | A SHA-256 hash in lowercase hexadecimal notation
newtype Sha256Hash =
  Sha256Hash {
    unSha256Hash :: String}
  deriving (Eq, Ord, Read, Show)

_Sha256Hash = Core.Name "hydra.build.format.Sha256Hash"

-- | Validation rules applying to term-definition bodies. Absent fields mean the corresponding check is not configured.
data TermValidationProfile =
  TermValidationProfile {
    -- | Whether duplicate let bindings are reported
    termValidationProfileDuplicateBinding :: (Maybe Severity),
    -- | Whether empty term annotations are reported
    termValidationProfileEmptyTermAnnotation :: (Maybe Severity),
    -- | Whether references to undefined variables are reported
    termValidationProfileUndefinedVariable :: (Maybe Severity)}
  deriving (Eq, Ord, Read, Show)

_TermValidationProfile = Core.Name "hydra.build.format.TermValidationProfile"

_TermValidationProfile_duplicateBinding = Core.Name "duplicateBinding"

_TermValidationProfile_emptyTermAnnotation = Core.Name "emptyTermAnnotation"

_TermValidationProfile_undefinedVariable = Core.Name "undefinedVariable"

-- | Validation rules applying to type-definition bodies. Absent fields mean the corresponding check is not configured.
data TypeValidationProfile =
  TypeValidationProfile {
    -- | Whether empty type annotations are reported
    typeValidationProfileEmptyAnnotation :: (Maybe Severity),
    -- | Whether duplicate field names within a record or union are reported
    typeValidationProfileDuplicateField :: (Maybe Severity),
    -- | Whether single-variant unions are reported
    typeValidationProfileSingleVariantUnion :: (Maybe Severity)}
  deriving (Eq, Ord, Read, Show)

_TypeValidationProfile = Core.Name "hydra.build.format.TypeValidationProfile"

_TypeValidationProfile_emptyAnnotation = Core.Name "emptyAnnotation"

_TypeValidationProfile_duplicateField = Core.Name "duplicateField"

_TypeValidationProfile_singleVariantUnion = Core.Name "singleVariantUnion"