topmark.config.validation¶
Stage-aware validation logs for config loading and preflight checks.
This module defines small, typed containers that group shared diagnostics by
validation stage during TopMark's config-loading lifecycle. It complements the
generic diagnostic substrate in
topmark.diagnostic.model rather than replacing
it: diagnostics remain ordinary Diagnostic
entries collected in a mutable
MutableDiagnosticLog or
immutable FrozenDiagnosticLog,
while this module adds stage-aware structure around those logs.
The staged model currently distinguishes three validation stages:
TOML_SOURCE: whole-source TOML validation and other source-local TOML issues.MERGED_CONFIG: layered-config deserialization, merge-time checks, config invariants, and typed override-application diagnostics.RUNTIME_APPLICABILITY: sanitization recoveries and other preflight/runtime applicability diagnostics.
These containers serve two roles in the current staged config-validation model:
- preserve stage-local diagnostics so validation boundaries remain explicit,
- provide a flattened compatibility view in stage order for callers that still
consume a single
MutableDiagnosticLogat reporting or output boundaries.
ValidationStage ¶
Bases: str, Enum
Named validation stages for config-loading and preflight diagnostics.
MutableValidationLogs
dataclass
¶
MutableValidationLogs(
*,
toml_source=MutableDiagnosticLog(),
merged_config=MutableDiagnosticLog(),
runtime_applicability=MutableDiagnosticLog(),
)
Mutable staged diagnostic logs for config validation.
Attributes:
| Name | Type | Description |
|---|---|---|
toml_source |
MutableDiagnosticLog
|
Diagnostics from whole-source TOML validation and source-local TOML issues. |
merged_config |
MutableDiagnosticLog
|
Diagnostics from layered config deserialization, merge-time checks, invariants, and typed override application. |
runtime_applicability |
MutableDiagnosticLog
|
Diagnostics from sanitization and recoverable runtime/preflight applicability checks. |
freeze ¶
Return an immutable snapshot of the staged validation logs.
Source code in src/topmark/config/validation.py
merge_with ¶
Return staged validation logs merged with a higher-precedence draft.
Diagnostics accumulate within each validation stage. The merged result keeps
this instance's diagnostics first and appends diagnostics from the
higher-precedence other draft afterward, preserving insertion order within
each stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
MutableValidationLogs
|
Higher-precedence staged validation logs to append. |
required |
Returns:
| Type | Description |
|---|---|
MutableValidationLogs
|
A new staged validation-log container containing the merged result. |
Source code in src/topmark/config/validation.py
flattened ¶
Return a flattened compatibility view in stage order.
Diagnostics are concatenated without rewriting their messages so the flattened compatibility diagnostic view remains stable at reporting and output boundaries.
Source code in src/topmark/config/validation.py
FrozenValidationLogs
dataclass
¶
Immutable staged diagnostic logs for immutable FrozenConfig snapshots.
thaw ¶
Return a mutable copy of these staged validation logs.
Source code in src/topmark/config/validation.py
flattened ¶
Return a flattened immutable compatibility view in stage order.
This helper is intended for reporting and output boundaries that still consume a single immutable diagnostic log.