Skip to content

v0.0.17

New: Alternative Keys for DbModel

Alternative keys (AK) provide human-readable, cross-table unique identifiers as an alternative to auto-increment primary keys. Annotate fields with (AK) to declare them as alternative key components.

  • (AK) field annotation in lythonic.state — marks fields as alternative key components. create_ddl emits a UNIQUE constraint for AK fields.
  • AltKey class — builds from a model's AK fields, computes a cascade JOIN chain across FK references, and resolves AK values to PKs via AltKey.resolve().
  • DbModel.resolve_ak() / load_by_ak() / to_ak_dict() — delegate methods for AK resolution, loading, and serialization directly on models.
  • Schema.table_map — validates AK-FK references at schema construction time.

New: Reference Type Hierarchy

Replaces the old GRef with a proper type hierarchy for referencing Python objects by path.

  • NsRef — namespace reference with scope:name format. Supports equality with strings, ordering (__lt__), and Pydantic serialization. Registered as a KnownType for DB roundtrips.
  • GlobalRef — extends NsRef for module-qualified Python objects (module.path:name). Replaces GRef throughout the codebase.
  • ModuleRef — lightweight reference to a Python module by import path.
  • DagPath in lythonic.compose.namespace — compound type for DAG execution paths (base NsRef + optional /label[idx] segments for sub-DAG iterations). DagContext.dag_nsref now uses DagPath.
  • NsNodeConfig.nsref is now NsRef | str | None with a model validator that defaults from gref when omitted.

Changed

  • NamespaceNode.nsref property returns NsRef instead of str. Callers that need a string use str(node.nsref).
  • Namespace.__getattr__ removed — dot-access to nodes by leaf name was unused outside its own tests. Use ns.get("nsref") instead.
  • lythonic.periodic module removed in favor of external crontier package.

Fixes

  • Flaky CI testtest_pushback_recorded_on_exception relied on probabilistic refresh with p≈0.995, causing ~0.5% flake rate. Now patches random.random to guarantee the refresh path.
  • basedpyright warnings — suppressed false positives on classmethod TypeVar resolution in DbModel.load_by_id / load_by_ak.