Drift — API
The facade of the domain package goga.drift — the structural drift report between the declared and the code-derived views.
The signatures below are the CODEMANIFEST contracts of the cell.
drift(cells: list[str] = [], max_depth: int | None = None, depends_on: list[str] = []) -> list[DriftEntry]
compare_views(schema_tree: list[SchemaNode], codegraph_tree: list[CodegraphNode]) -> list[DriftEntry]
scope_entries(
entries: list[DriftEntry],
schema_tree: list[SchemaNode], codegraph_tree: list[CodegraphNode],
) -> list[DriftEntry]
drift builds the two complete views (schema([], None, []) and codegraph([], None, [])), compares them, and scopes the result by the two filtered views (schema(cells, max_depth, depends_on) and codegraph(cells, max_depth, depends_on)) — the filters select what is reported, never what is compared. The run is wrapped by the two drift moments and observed by the installed tool packages: the settled report passes the report amendment, every surviving entry passes the entry-facts amendment, and the routine returns the settled post-amendment list — the last adjusting tool's replacement when any tool adjusted, the scoped report otherwise; with no tool packages installed the report is identical to the run without the extension. It returns the flat list of DriftEntry records in the stable order (cell path, then kind); the caller owns the serialization (see CLI for the output shape). The routine reads no manifests and no sources itself — the views arrive fully assembled from the two producers — and never prints.
compare_views and scope_entries are the two pure steps behind it: the name-level comparison of two complete view trees (SchemaNode from goga.schema.hooks, CodegraphNode from goga.codegraph.facts) and the survival scoping of computed entries over two filtered view trees — an entry survives iff its cell survives in at least one of the two filtered views; the input order is preserved, and no entry is fabricated, altered, or reordered.
DriftEntry is a frozen keyword-only record:
| Field | Type | Description |
|---|---|---|
kind |
str |
Direction of the discrepancy — schema_only or codegraph_only |
cell |
str |
Normalized cell path of the discrepancy subject |
types |
list[str] \| None |
Sorted type names missing from the other view; None marks a cell-level discrepancy |
tools |
dict[str, dict[str, object]] |
The committed tools overlay of the entry; {} when no tool contributed — the entry-facts amendment alone places non-empty overlays |
Raises:
FileNotFoundError—.goga/config.ymlis absent (the uninitialized-project error of the code-derived view).ValueError— manifest loading and validation failures, the configured language is outsidepython,golang,javascript,kotlin,swift, a source file fails to parse (the message names the file), a schema or codegraph checkpoint hard-fails — every producer error propagates unchanged — or a drift amendment hard-fails: a crashed hook or a malformed adjustment or contribution, the message naming the hook or tool, the action, the entry subject where one exists, and the reason.ImportError— a tool-package facade failed to import (the message names the package); the run never started, so no completion moment fires.
The routine is read-only, deterministic, and idempotent — identical project state, configuration, and filters produce identical reports.