oct
Loading...
Searching...
No Matches
oct.complexity.baseline Namespace Reference

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

Detailed Description

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)

Function Documentation

◆ _is_worse()

bool oct.complexity.baseline._is_worse ( BaselineEntry candidate,
BaselineEntry existing )
protected
Return whether *candidate* records more debt than *existing*.

Definition at line 97 of file baseline.py.

Here is the caller graph for this function:

◆ _parse_document()

dict[str, BaselineEntry] oct.complexity.baseline._parse_document ( object document,
Path target )
protected
Validate one loaded baseline document into entries by identity.

Definition at line 145 of file baseline.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _parse_entry()

BaselineEntry oct.complexity.baseline._parse_entry ( object item,
Path target )
protected
Validate one baseline entry or refuse the whole document.

Definition at line 169 of file baseline.py.

Here is the caller graph for this function:

◆ build_entries()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_baseline()

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.

Here is the call graph for this function:

◆ render_baseline()

str oct.complexity.baseline.render_baseline ( Sequence[BaselineEntry] entries)
Return the deterministic baseline document text.

Definition at line 104 of file baseline.py.

Here is the caller graph for this function:

◆ write_baseline()

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.

Here is the call graph for this function:

Variable Documentation

◆ BASELINE_SCHEMA_VERSION

int oct.complexity.baseline.BASELINE_SCHEMA_VERSION = 1

Definition at line 53 of file baseline.py.