@conformetry/core
v0.0.31
Published
Core types and structured contracts for the Conformetry code generation and conformance toolchain
Maintainers
Readme
👔 Conformetry Core
The shared contract every other Conformetry
package builds on. It is the contracts leaf of the five-layer spine — core <-
configuration <- analysis <- output <- cli — so it declares types and holds
nothing executable: no service, no NestJS module, no dependency on anything
else in the conformetry graph. Importing a result type from here therefore
drags nothing behind it.
npm install --save-dev @conformetry/coreWhat it owns
| File | Responsibility |
| ---- | -------------- |
| lib/differences.types.ts | The structured ConformetryDifference shape, and the language and category unions that discriminate it |
| lib/inventory.types.ts | What discovery found, as the output layer renders it: templates, instances, and the pairings between them |
| lib/runner.types.ts | The ConformetryLanguageValidator contract and the document, payload, and result shapes it is spoken in |
| lib/scoring.types.ts | InstanceScore: how well one matched instance honours the template it matched |
The behavior these types describe lives above them. The difference and scoring
primitives, the file-existence pass, and every per-format validator are in
@conformetry/languages; the validator
envelope is in @conformetry/validation;
rendering is in @conformetry/output.
"Language" here means a validator for one file format — TypeScript, JSON,
markdown, Python. The word "plugin" is reserved for the Nx plugin in
@conformetry/nx, and is deliberately not used
for these.
Writing a language validator
A validator supplies a descriptor and a single-document comparison. Extension
filtering, grouping differences under their file, and assembling the result are
handled once by RunnerService in @conformetry/validation, so a language
package contains only its comparison logic:
@Injectable()
export class ExampleValidatorService implements ConformetryLanguageValidator {
public readonly descriptor = EXAMPLE_VALIDATOR_DESCRIPTOR;
public validateDocument(
document: PreparedValidationDocument,
): DocumentValidationResult {
// compare document.renderedTemplate against document.instance
return { differences, totalWeight };
}
}Weight and score
A validator reports how much the template asked for alongside what it found.
totalWeight counts every requirement the comparison weighed — conforming ones
included, because leaving them out would score an instance only against the
parts of itself that are already wrong.
Each difference may carry a weight, defaulting to 1. It says how many
requirements that one finding stands in for: a validator reports a missing
class once, however many members it held, so weighing the finding by its
subtree is what keeps deleting a class from costing the same as deleting an
import. No per-kind weight table is needed — a class is worth more because it
contains more.
score = (totalWeight - sum(difference.weight ?? 1)) / totalWeightScoringService, in @conformetry/languages, owns that arithmetic, including
the two cases worth getting right once: the default weight of a finding that
declares none, and an empty template whose denominator is zero and which
therefore conforms perfectly.
@conformetry/validation drives the
registered validators; they are never responsible for discovering files or
loading configuration.
Structured differences
Differences carry the location on both sides — instance and template — along
with the expected value and a concrete fix. That last field is the point:
reports are meant to be actionable by whoever, or whatever, has to make the
file conform. Prefer populating instanceLine/templateLine (or
instancePath for document formats) over folding a location into the message.
Exports
Types only: ConformetryDifference, ConformetryDifferenceLanguage,
ConformetryDifferenceType, ConformetryLanguageValidator,
DocumentValidationResult, InstanceScore, InventoriedInstance,
InventoriedPairing, InventoriedTemplate, LanguageValidatorDescriptor,
LanguageValidatorResult, PreparedValidationDocument,
PreparedValidationPayload, and ValidationFileResult.
Test
nx run conformetry-core:vitestOne test, and it asserts the property that makes this package a leaf: the module contributes nothing at runtime, so importing a result type from here cannot drag a service or a NestJS module behind it. Exporting one value fails it.
License
MIT — see LICENSE.
👔 Conformetry
This project was generated from the nestjs-service-project conformetry template.
🔭 Callidescope
Call stacks traced through projects/ic-suite/conformetry/conformetry-core, deepest first. Each frame shows what it takes, what it returns, and what its documentation says.
| Measure | Value | | --- | --- | | Callables | 1 | | Files | 11 | | Calls traced | 0 | | Call stacks | 0 | | Deepest stack | 0 | | Stacks through recursion | 0 | | Unfollowable calls | 0 |
Limits
What this project is judged against, as declared in its own callidescope.config.ts.
| Limit | Value |
| --- | --- |
| maximumDepth | 1 |
| maximumBreadth | 1 |
Call stacks (depth)
None.
Breadth
None.
🕸️ Codependix
Dependency graphs exported by codependix, regenerated by nx run configuration:codependix:write.
Nx Neighborhood
graph LR
conformetry_cli["conformetry-cli"]
conformetry_configuration["conformetry-configuration"]
conformetry_core["conformetry-core"]
conformetry_languages["conformetry-languages"]
conformetry_output["conformetry-output"]
conformetry_validation["conformetry-validation"]
conformetry_cli --> conformetry_core
conformetry_configuration --> conformetry_core
conformetry_languages --> conformetry_core
conformetry_output --> conformetry_core
conformetry_validation --> conformetry_core
classDef subject fill:#7c3aed,color:#fff,stroke:#4c1d95,stroke-width:2px
class conformetry_core subjectNestJS Module Graph
flowchart LR
ConformetryCoreModuleFile Imports
graph LR
file_callidescope_config_ts["callidescope.config.ts"]
file_codependix_config_ts["codependix.config.ts"]
file_codometer_config_ts["codometer.config.ts"]
file_eslint_config_ts["eslint.config.ts"]
file_src_index_ts["src/index.ts"]
file_src_index_unit_test_ts["src/index.unit.test.ts"]
file_src_modules_conformetry_core_conformetry_core_constants_ts["src/modules/conformetry-core/conformetry-core.constants.ts"]
file_src_modules_conformetry_core_conformetry_core_module_ts["src/modules/conformetry-core/conformetry-core.module.ts"]
file_src_modules_conformetry_core_conformetry_core_service_ts["src/modules/conformetry-core/conformetry-core.service.ts"]
file_src_modules_conformetry_core_conformetry_core_service_unit_test_ts["src/modules/conformetry-core/conformetry-core.service.unit.test.ts"]
file_src_modules_conformetry_core_conformetry_core_types_ts["src/modules/conformetry-core/conformetry-core.types.ts"]
file_testing_mocks_ts["testing/mocks.ts"]
file_testing_setup_ts["testing/setup.ts"]
file_vite_config_ts["vite.config.ts"]
file_vitest_config_ts["vitest.config.ts"]
file_src_index_unit_test_ts --> file_src_index_ts
file_src_modules_conformetry_core_conformetry_core_module_ts --> file_src_modules_conformetry_core_conformetry_core_service_ts
file_src_modules_conformetry_core_conformetry_core_service_unit_test_ts --> file_src_modules_conformetry_core_conformetry_core_service_ts⏲️ Codometer
Project
Measured Targets
TypeScript
JavaScript
Python
JSON
YAML
TOML
Shell
SQL
HCL
CSS
Conventions
Jupyter
Markdown
