|
oct
|
Classes | |
| class | BaselineEntry |
Functions | |
| tuple[BaselineEntry,...] | build_entries (Sequence[FunctionResult] results, str|Path root) |
| bool | _is_worse (BaselineEntry candidate, BaselineEntry existing) |
| str | render_baseline (Sequence[BaselineEntry] entries) |
| int | write_baseline (str|Path path, Sequence[FunctionResult] results, str|Path root) |
| dict[str, BaselineEntry] | load_baseline (str|Path path) |
| dict[str, BaselineEntry] | _parse_document (object document, Path target) |
| BaselineEntry | _parse_entry (object item, Path target) |
Variables | |
| int | BASELINE_SCHEMA_VERSION = 1 |
Purpose
-------
Record and reload accepted complexity debt for the don't-get-worse ratchet.
Responsibilities
----------------
- Build one stable ``relpath::qualname`` record per measured function.
- Write byte-deterministic, sorted, schema-versioned baseline documents.
- Reload a baseline, refusing anything malformed instead of ignoring it.
Diagnostics
-----------
Domain: OCT-COMPLEXITY
Levels:
L2 - baseline lifecycle
L3 - entry and schema details
L4 - deep tracing
Contracts
---------
- Two writes of the same measurements produce identical bytes.
- A baseline this module cannot fully understand is refused, never partially
honoured: a half-read baseline silently grandfathers real debt.
- The module imports only the Python standard library and sibling measurement
modules.
Dependencies
------------
- oct.complexity.service (result rows and function identity)
- oct.complexity.thresholds (the shared named-refusal error)
|
protected |
Return whether *candidate* records more debt than *existing*.
Definition at line 97 of file baseline.py.
|
protected |
Validate one loaded baseline document into entries by identity.
Definition at line 145 of file baseline.py.
|
protected |
Validate one baseline entry or refuse the whole document.
Definition at line 169 of file baseline.py.
| tuple[BaselineEntry, ...] oct.complexity.baseline.build_entries | ( | Sequence[FunctionResult] | results, |
| str | Path | root ) |
Return one sorted entry per measured function, worst value winning. Two rows can only collide when the same file is reached by two targets, and keeping the worse of the pair means a collision can never soften the recorded debt.
Definition at line 73 of file baseline.py.
| dict[str, BaselineEntry] oct.complexity.baseline.load_baseline | ( | str | Path | path | ) |
Return the recorded entries by identity, refusing anything malformed.
Definition at line 129 of file baseline.py.
| str oct.complexity.baseline.render_baseline | ( | Sequence[BaselineEntry] | entries | ) |
Return the deterministic baseline document text.
Definition at line 104 of file baseline.py.
| int oct.complexity.baseline.write_baseline | ( | str | Path | path, |
| Sequence[FunctionResult] | results, | ||
| str | Path | root ) |
Write the baseline for *results* and return how many were recorded.
Definition at line 113 of file baseline.py.
| int oct.complexity.baseline.BASELINE_SCHEMA_VERSION = 1 |
Definition at line 53 of file baseline.py.